react-native-plaid-link-sdk 12.8.3 → 12.8.4
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 +1 -0
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/plaid/PlaidModule.kt +60 -8
- package/dist/EmbeddedLink/EmbeddedLinkView.d.ts +13 -0
- package/dist/{build/EmbeddedLink → EmbeddedLink}/EmbeddedLinkView.js +0 -1
- package/dist/EmbeddedLink/EmbeddedLinkView.web.d.ts +1 -0
- package/dist/EmbeddedLink/EmbeddedLinkView.web.js +1 -0
- package/dist/{build/EmbeddedLink → EmbeddedLink}/NativeEmbeddedLinkView.js +0 -1
- package/dist/PlaidLink.d.ts +27 -0
- package/dist/{build/PlaidLink.js → PlaidLink.js} +8 -21
- package/dist/Types.d.ts +539 -0
- package/dist/{build/Types.js → Types.js} +0 -8
- package/dist/fabric/EmbeddedLinkViewNativeComponent.d.ts +15 -0
- package/dist/{build/fabric → fabric}/EmbeddedLinkViewNativeComponent.js +0 -1
- package/dist/fabric/NativePlaidLinkModuleAndroid.d.ts +14 -0
- package/dist/{build/fabric → fabric}/NativePlaidLinkModuleAndroid.js +0 -1
- package/dist/fabric/NativePlaidLinkModuleiOS.d.ts +15 -0
- package/dist/{build/fabric → fabric}/NativePlaidLinkModuleiOS.js +0 -1
- package/dist/fabric/fabricUtils.d.ts +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/ios/RNLinksdk.mm +1 -1
- package/package.json +1 -1
- package/react-native-plaid-link-sdk.podspec +1 -1
- package/dist/build/EmbeddedLink/EmbeddedLinkView.d.ts +0 -2
- package/dist/build/EmbeddedLink/EmbeddedLinkView.web.d.ts +0 -1
- package/dist/build/EmbeddedLink/EmbeddedLinkView.web.js +0 -2
- package/dist/build/PlaidEmbeddedSearchView.d.ts +0 -2
- package/dist/build/PlaidEmbeddedSearchView.js +0 -25
- package/dist/build/PlaidLink.d.ts +0 -7
- package/dist/build/ReactNativePlaidLinkSdk.types.d.ts +0 -108
- package/dist/build/ReactNativePlaidLinkSdk.types.js +0 -469
- package/dist/build/ReactNativePlaidLinkSdkModule.d.ts +0 -2
- package/dist/build/ReactNativePlaidLinkSdkModule.js +0 -4
- package/dist/build/ReactNativePlaidLinkSdkView.d.ts +0 -2
- package/dist/build/ReactNativePlaidLinkSdkView.js +0 -7
- package/dist/build/Types.d.ts +0 -108
- package/dist/build/fabric/EmbeddedLinkViewNativeComponent.d.ts +0 -2
- package/dist/build/fabric/NativePlaidLinkModuleAndroid.d.ts +0 -2
- package/dist/build/fabric/NativePlaidLinkModuleiOS.d.ts +0 -2
- package/dist/build/fabric/fabricUtils.js +0 -2
- package/dist/build/index.d.ts +0 -14
- package/dist/build/index.js +0 -154
- package/dist/{build/EmbeddedLink → EmbeddedLink}/NativeEmbeddedLinkView.d.ts +1 -1
- /package/dist/{src/__tests__ → __tests__}/Types.tests.d.ts +0 -0
- /package/dist/{src/__tests__ → __tests__}/Types.tests.js +0 -0
- /package/dist/{build/fabric/fabricUtils.d.ts → fabric/fabricUtils.js} +0 -0
package/README.md
CHANGED
|
@@ -215,6 +215,7 @@ If migrating from older versions, see the [docs](https://plaid.com/docs/link/rea
|
|
|
215
215
|
|
|
216
216
|
| Plaid SDK Version | Min React Native Version | Android SDK | Android Min Version | Android Compile Version| iOS SDK | iOS Min Version | Status |
|
|
217
217
|
|-------------------|--------------------------|-------------|---------------------|------------------------|---------|-----------------|-------------------------------|
|
|
218
|
+
| 12.8.4 | * | [5.5.2+] | 21 | 34 | >=6.4.7 | 14.0 | Active, supports Xcode 16.1.0 |
|
|
218
219
|
| 12.8.3 | * | [5.5.1+] | 21 | 34 | >=6.4.3 | 14.0 | Active, supports Xcode 16.1.0 |
|
|
219
220
|
| 12.8.2 | * | [5.5.1+] | 21 | 34 | >=6.4.3 | 14.0 | Active, supports Xcode 16.1.0 |
|
|
220
221
|
| 12.8.1 | * | [5.5.2+] | 21 | 34 | >=6.4.3 | 14.0 | Active, supports Xcode 16.1.0 |
|
|
@@ -38,11 +38,18 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
38
38
|
|
|
39
39
|
private val jsonConverter by lazy { PlaidJsonConverter() }
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Written on the RN native-modules thread (open/create), read and cleared on the
|
|
42
|
+
// main thread (onActivityResult); @Volatile for cross-thread visibility.
|
|
43
|
+
@Volatile private var onSuccessCallback: Callback? = null
|
|
44
|
+
@Volatile private var onExitCallback: Callback? = null
|
|
43
45
|
|
|
44
46
|
private var plaidHandler: PlaidHandler? = null
|
|
45
47
|
|
|
48
|
+
// Tracks whether this module has created a Link session in this process. Guards
|
|
49
|
+
// releaseCurrentSession() so Plaid.destroy() isn't called when there is nothing to
|
|
50
|
+
// release, which would tear down sessions this module doesn't own (e.g. embedded Link).
|
|
51
|
+
private var didCreateSession = false
|
|
52
|
+
|
|
46
53
|
companion object {
|
|
47
54
|
private const val LINK_TOKEN_PREFIX = "link"
|
|
48
55
|
|
|
@@ -114,6 +121,12 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
114
121
|
throw LinkException("Unable to open link, please check that your configuration is valid")
|
|
115
122
|
}
|
|
116
123
|
|
|
124
|
+
// Tear down any previous session before creating a new one. Without this, a stale session (e.g. the
|
|
125
|
+
// user bypassed the OAuth redirect and relaunched Link) leaves old callbacks in place, and its result
|
|
126
|
+
// can re-invoke a spent RN Callback, crashing with "This callback type only permits a single
|
|
127
|
+
// invocation from native code."
|
|
128
|
+
releaseCurrentSession()
|
|
129
|
+
|
|
117
130
|
// Set the event listener here instead of in open for Layer use cases.
|
|
118
131
|
try {
|
|
119
132
|
Plaid.setLinkEventListener { linkEvent: LinkEvent ->
|
|
@@ -139,6 +152,7 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
139
152
|
}
|
|
140
153
|
}
|
|
141
154
|
)
|
|
155
|
+
this.didCreateSession = true
|
|
142
156
|
}
|
|
143
157
|
|
|
144
158
|
@ReactMethod
|
|
@@ -194,6 +208,10 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
194
208
|
onExitCallback: Callback
|
|
195
209
|
) {
|
|
196
210
|
val activity = reactApplicationContext.currentActivity ?: throw IllegalStateException("Current activity is null")
|
|
211
|
+
|
|
212
|
+
// Tear down any previous session before starting a new one. See create() for rationale.
|
|
213
|
+
releaseCurrentSession()
|
|
214
|
+
|
|
197
215
|
this.onSuccessCallback = onSuccessCallback
|
|
198
216
|
this.onExitCallback = onExitCallback
|
|
199
217
|
|
|
@@ -207,10 +225,12 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
207
225
|
|
|
208
226
|
val tokenConfiguration = getLinkTokenConfiguration(token, noLoadingState, getLogLevel(logLevel))
|
|
209
227
|
tokenConfiguration?.let {
|
|
210
|
-
Plaid.create(
|
|
228
|
+
val handler = Plaid.create(
|
|
211
229
|
reactApplicationContext.getApplicationContext() as Application,
|
|
212
230
|
it
|
|
213
|
-
)
|
|
231
|
+
)
|
|
232
|
+
this.didCreateSession = true
|
|
233
|
+
handler.open(activity)
|
|
214
234
|
return
|
|
215
235
|
}
|
|
216
236
|
|
|
@@ -225,6 +245,32 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
225
245
|
|
|
226
246
|
override fun removeListeners(count: Double) = Unit
|
|
227
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Releases the current Link session: drops any pending success/exit callbacks, clears the cached
|
|
250
|
+
* handler, and tears down the underlying Plaid SDK resources (preloaded WebView / token component)
|
|
251
|
+
* via [Plaid.destroy]. Safe to call when no session exists (no-op). Used before creating a new
|
|
252
|
+
* session so a stale session cannot deliver a result into spent callbacks.
|
|
253
|
+
*
|
|
254
|
+
* Plaid.destroy() is deliberately called synchronously on the calling (RN native-modules) thread
|
|
255
|
+
* rather than posted to the main looper: the caller creates the replacement session immediately
|
|
256
|
+
* afterwards on this thread, and an async destroy could run after Plaid.create() and null the new
|
|
257
|
+
* session's token component.
|
|
258
|
+
*/
|
|
259
|
+
private fun releaseCurrentSession() {
|
|
260
|
+
onSuccessCallback = null
|
|
261
|
+
onExitCallback = null
|
|
262
|
+
plaidHandler = null
|
|
263
|
+
if (!didCreateSession) {
|
|
264
|
+
return
|
|
265
|
+
}
|
|
266
|
+
didCreateSession = false
|
|
267
|
+
try {
|
|
268
|
+
Plaid.destroy()
|
|
269
|
+
} catch (ex: Exception) {
|
|
270
|
+
Log.w("PlaidModule", "Failed to destroy previous Plaid session", ex)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
228
274
|
private fun maybeGetStringField(obj: JSONObject, fieldName: String): String? {
|
|
229
275
|
if (obj.has(fieldName) && !TextUtils.isEmpty(obj.getString(fieldName))) {
|
|
230
276
|
return obj.getString(fieldName)
|
|
@@ -267,13 +313,19 @@ class PlaidModule internal constructor(reactContext: ReactApplicationContext) :
|
|
|
267
313
|
val linkHandler = LinkResultHandler(
|
|
268
314
|
onSuccess = { success ->
|
|
269
315
|
val result = convertJsonToMap(JSONObject(jsonConverter.convert(success)))
|
|
270
|
-
|
|
271
|
-
|
|
316
|
+
// Capture and null both callbacks before invoking so a duplicate result delivery cannot
|
|
317
|
+
// re-invoke a single-use RN Callback.
|
|
318
|
+
val callback = this.onSuccessCallback
|
|
319
|
+
this.onSuccessCallback = null
|
|
320
|
+
this.onExitCallback = null
|
|
321
|
+
callback?.invoke(result)
|
|
272
322
|
},
|
|
273
323
|
onExit = { exit ->
|
|
274
324
|
val result = convertJsonToMap(JSONObject(jsonConverter.convert(exit)))
|
|
275
|
-
|
|
276
|
-
this.
|
|
325
|
+
val callback = this.onExitCallback
|
|
326
|
+
this.onSuccessCallback = null
|
|
327
|
+
this.onExitCallback = null
|
|
328
|
+
callback?.invoke(result)
|
|
277
329
|
}
|
|
278
330
|
)
|
|
279
331
|
|
|
@@ -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 @@
|
|
|
1
|
+
export declare const EmbeddedLinkView: () => null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EmbeddedLinkView = () => null;
|
|
@@ -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;
|
|
@@ -31,18 +31,17 @@ export const usePlaidEmitter = (linkEventListener) => {
|
|
|
31
31
|
}, []);
|
|
32
32
|
};
|
|
33
33
|
export const create = (props) => {
|
|
34
|
-
var _a, _b
|
|
34
|
+
var _a, _b;
|
|
35
35
|
let token = props.token;
|
|
36
36
|
let noLoadingState = (_a = props.noLoadingState) !== null && _a !== void 0 ? _a : false;
|
|
37
37
|
if (Platform.OS === 'android') {
|
|
38
|
-
RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.
|
|
38
|
+
RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.create(token, noLoadingState, (_b = props.logLevel) !== null && _b !== void 0 ? _b : LinkLogLevel.ERROR);
|
|
39
39
|
}
|
|
40
40
|
else {
|
|
41
|
-
|
|
42
|
-
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.createPlaidLink(token, noLoadingState, onLoad);
|
|
41
|
+
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.create(token, noLoadingState);
|
|
43
42
|
}
|
|
44
43
|
};
|
|
45
|
-
export const open = (props) => {
|
|
44
|
+
export const open = (props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
45
|
if (Platform.OS === 'android') {
|
|
47
46
|
RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.open((result) => {
|
|
48
47
|
if (props.onSuccess != null) {
|
|
@@ -77,17 +76,6 @@ export const open = (props) => {
|
|
|
77
76
|
}
|
|
78
77
|
});
|
|
79
78
|
}
|
|
80
|
-
};
|
|
81
|
-
/**
|
|
82
|
-
* Clears any previously created Plaid session and associated resources
|
|
83
|
-
* that were captured during a prior call to create(). This method should
|
|
84
|
-
* be invoked before starting a new layer session with create() to ensure
|
|
85
|
-
* proper cleanup and avoid conflicts from lingering state or resources.
|
|
86
|
-
*/
|
|
87
|
-
export const destroy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
88
|
-
if (Platform.OS === 'android') {
|
|
89
|
-
yield (RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.destroy());
|
|
90
|
-
}
|
|
91
79
|
});
|
|
92
80
|
export const dismissLink = () => {
|
|
93
81
|
if (Platform.OS === 'ios') {
|
|
@@ -96,10 +84,10 @@ export const dismissLink = () => {
|
|
|
96
84
|
};
|
|
97
85
|
export const submit = (data) => {
|
|
98
86
|
if (Platform.OS === 'android') {
|
|
99
|
-
RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.submit(data.phoneNumber
|
|
87
|
+
RNLinksdkAndroid === null || RNLinksdkAndroid === void 0 ? void 0 : RNLinksdkAndroid.submit(data.phoneNumber);
|
|
100
88
|
}
|
|
101
89
|
else {
|
|
102
|
-
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.submit(data.phoneNumber
|
|
90
|
+
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.submit(data.phoneNumber);
|
|
103
91
|
}
|
|
104
92
|
};
|
|
105
93
|
/**
|
|
@@ -116,7 +104,7 @@ export const submit = (data) => {
|
|
|
116
104
|
* @warning This method can only be used once the user has granted access to their Apple card via a standard Link Session.
|
|
117
105
|
* @warning This method requires that your app has been granted FinanceKit access from Apple.
|
|
118
106
|
*/
|
|
119
|
-
export const syncFinanceKit = (token, requestAuthorizationIfNeeded,
|
|
107
|
+
export const syncFinanceKit = (token, requestAuthorizationIfNeeded, completion) => {
|
|
120
108
|
if (Platform.OS === 'android') {
|
|
121
109
|
completion({
|
|
122
110
|
type: FinanceKitErrorType.Unknown,
|
|
@@ -124,7 +112,7 @@ export const syncFinanceKit = (token, requestAuthorizationIfNeeded, simulatedBeh
|
|
|
124
112
|
});
|
|
125
113
|
}
|
|
126
114
|
else {
|
|
127
|
-
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.syncFinanceKit(token, requestAuthorizationIfNeeded,
|
|
115
|
+
RNLinksdkiOS === null || RNLinksdkiOS === void 0 ? void 0 : RNLinksdkiOS.syncFinanceKit(token, requestAuthorizationIfNeeded, () => {
|
|
128
116
|
completion();
|
|
129
117
|
}, (error) => {
|
|
130
118
|
completion({
|
|
@@ -134,4 +122,3 @@ export const syncFinanceKit = (token, requestAuthorizationIfNeeded, simulatedBeh
|
|
|
134
122
|
});
|
|
135
123
|
}
|
|
136
124
|
};
|
|
137
|
-
//# sourceMappingURL=PlaidLink.js.map
|