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.
- package/README.md +3 -1
- package/android/build.gradle +37 -1
- package/android/src/main/AndroidManifest.xml +1 -1
- package/android/src/main/java/com/plaid/PLKEmbeddedViewManager.kt +21 -5
- package/android/src/main/java/com/plaid/PlaidModule.kt +13 -12
- package/android/src/main/java/com/plaid/PlaidPackage.java +93 -22
- package/android/src/paper/java/com/facebook/react/viewmanagers/PLKEmbeddedViewManagerDelegate.java +34 -0
- package/android/src/paper/java/com/facebook/react/viewmanagers/PLKEmbeddedViewManagerInterface.java +18 -0
- package/android/src/paper/java/com/plaid/NativePlaidLinkModuleAndroidSpec.java +54 -0
- package/android/src/paper/java/com/plaid/NativePlaidLinkModuleiOSSpec.java +54 -0
- package/dist/EmbeddedLink/EmbeddedLinkView.d.ts +1 -1
- package/dist/EmbeddedLink/NativeEmbeddedLinkView.d.ts +1 -1
- package/dist/EmbeddedLink/NativeEmbeddedLinkView.js +1 -6
- package/dist/PlaidLink.d.ts +1 -1
- package/dist/PlaidLink.js +18 -16
- package/dist/fabric/EmbeddedLinkViewNativeComponent.d.ts +15 -0
- package/dist/fabric/EmbeddedLinkViewNativeComponent.js +2 -0
- package/dist/fabric/NativePlaidLinkModuleAndroid.d.ts +13 -0
- package/dist/fabric/NativePlaidLinkModuleAndroid.js +4 -0
- package/dist/fabric/NativePlaidLinkModuleiOS.d.ts +13 -0
- package/dist/fabric/NativePlaidLinkModuleiOS.js +4 -0
- package/dist/fabric/fabricUtils.d.ts +1 -0
- package/dist/fabric/fabricUtils.js +1 -0
- package/ios/PLKEmbeddedView.m +1 -1
- package/ios/PLKEmbeddedView.swift +4 -4
- package/ios/PLKEmbeddedViewComponentView.h +15 -0
- package/ios/PLKEmbeddedViewComponentView.mm +85 -0
- package/ios/PLKFabricHelpers.h +70 -0
- package/ios/RNLinksdk.h +10 -8
- package/ios/{RNLinksdk.m → RNLinksdk.mm} +20 -10
- package/ios/RNLinksdk.xcodeproj/project.pbxproj +20 -4
- package/ios/RNLinksdk.xcodeproj/project.xcworkspace/xcuserdata/dtroupe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNLinksdk.xcworkspace/xcuserdata/dtroupe.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/RNPlaidHelper.h +7 -0
- package/ios/RNPlaidHelper.m +10 -0
- package/ios/react_native_plaid_link_sdk.h +2 -0
- package/package.json +14 -4
- package/react-native-plaid-link-sdk.podspec +14 -2
- package/src/EmbeddedLink/EmbeddedLinkView.tsx +95 -0
- package/src/EmbeddedLink/EmbeddedLinkView.web.tsx +5 -0
- package/src/EmbeddedLink/NativeEmbeddedLinkView.tsx +3 -0
- package/src/PlaidLink.tsx +181 -0
- package/src/Types.ts +559 -0
- package/src/__tests__/Types.tests.ts +15 -0
- package/src/fabric/EmbeddedLinkViewNativeComponent.ts +24 -0
- package/src/fabric/NativePlaidLinkModuleAndroid.ts +26 -0
- package/src/fabric/NativePlaidLinkModuleiOS.ts +21 -0
- package/src/fabric/fabricUtils.ts +2 -0
- package/src/index.ts +21 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ViewProps } from 'react-native';
|
|
2
|
+
import { DirectEventHandler, UnsafeMixed } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
export interface NativeProps extends ViewProps {
|
|
4
|
+
token?: string;
|
|
5
|
+
iOSPresentationStyle?: string;
|
|
6
|
+
onEmbeddedEvent: DirectEventHandler<{
|
|
7
|
+
embeddedEventName: string;
|
|
8
|
+
eventName?: string;
|
|
9
|
+
error?: UnsafeMixed;
|
|
10
|
+
publicToken?: string;
|
|
11
|
+
metadata?: UnsafeMixed;
|
|
12
|
+
}>;
|
|
13
|
+
}
|
|
14
|
+
declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TurboModule } from 'react-native';
|
|
2
|
+
import { Double } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import { UnsafeObject } from './fabricUtils';
|
|
4
|
+
import { LinkSuccess, LinkExit } from '../Types';
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
create(token: string, noLoadingState: boolean, logLevel: string): void;
|
|
7
|
+
open(onSuccess: (result: UnsafeObject<LinkSuccess>) => void, onExit: (result: UnsafeObject<LinkExit>) => void): void;
|
|
8
|
+
startLinkActivityForResult(token: string, noLoadingState: boolean, logLevel: string, onSuccessCallback: (result: UnsafeObject<LinkSuccess>) => void, onExitCallback: (result: UnsafeObject<LinkExit>) => void): void;
|
|
9
|
+
addListener(eventName: string): void;
|
|
10
|
+
removeListeners(count: Double): void;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: Spec | null;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TurboModule } from 'react-native';
|
|
2
|
+
import { Int32 } from 'react-native/Libraries/Types/CodegenTypes';
|
|
3
|
+
import { UnsafeObject } from './fabricUtils';
|
|
4
|
+
import { LinkSuccess, LinkExit, LinkError } from '../Types';
|
|
5
|
+
export interface Spec extends TurboModule {
|
|
6
|
+
create(token: string, noLoadingState: boolean): void;
|
|
7
|
+
open(fullScreen: boolean, onSuccess: (result: UnsafeObject<LinkSuccess>) => void, onExit: (error: UnsafeObject<LinkError>, result: UnsafeObject<LinkExit>) => void): void;
|
|
8
|
+
dismiss(): void;
|
|
9
|
+
addListener(eventName: string): void;
|
|
10
|
+
removeListeners(count: Int32): void;
|
|
11
|
+
}
|
|
12
|
+
declare const _default: Spec | null;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type UnsafeObject<T> = T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/ios/PLKEmbeddedView.m
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
import LinkKit
|
|
2
2
|
import UIKit
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
@objc public final class PLKEmbeddedView: UIView {
|
|
5
5
|
|
|
6
6
|
// Properties exposed to React Native.
|
|
7
7
|
|
|
8
|
-
@objc var iOSPresentationStyle: String = "" {
|
|
8
|
+
@objc public var iOSPresentationStyle: String = "" {
|
|
9
9
|
didSet {
|
|
10
10
|
createNativeEmbeddedView()
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
@objc var token: String = "" {
|
|
14
|
+
@objc public var token: String = "" {
|
|
15
15
|
didSet {
|
|
16
16
|
createNativeEmbeddedView()
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
@objc var onEmbeddedEvent: RCTDirectEventBlock?
|
|
20
|
+
@objc public var onEmbeddedEvent: RCTDirectEventBlock?
|
|
21
21
|
|
|
22
22
|
// MARK: Private
|
|
23
23
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import <UIKit/UIKit.h>
|
|
4
|
+
|
|
5
|
+
#import <React/RCTUIManager.h>
|
|
6
|
+
#import <React/RCTViewComponentView.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface PLKEmbeddedViewComponentView : RCTViewComponentView
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
14
|
+
|
|
15
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
|
|
3
|
+
#import "PLKEmbeddedViewComponentView.h"
|
|
4
|
+
#import "PLKFabricHelpers.h"
|
|
5
|
+
|
|
6
|
+
#import <React/RCTBridge+Private.h>
|
|
7
|
+
#import <React/RCTConversions.h>
|
|
8
|
+
#import <React/RCTFabricComponentsPlugins.h>
|
|
9
|
+
|
|
10
|
+
#import <react/renderer/components/rnplaidlink/ComponentDescriptors.h>
|
|
11
|
+
#import <react/renderer/components/rnplaidlink/EventEmitters.h>
|
|
12
|
+
#import <react/renderer/components/rnplaidlink/Props.h>
|
|
13
|
+
#import <react/renderer/components/rnplaidlink/RCTComponentViewHelpers.h>
|
|
14
|
+
|
|
15
|
+
using namespace facebook::react;
|
|
16
|
+
|
|
17
|
+
@implementation PLKEmbeddedViewComponentView {
|
|
18
|
+
PLKEmbeddedView *_view;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
- (instancetype)initWithFrame:(CGRect)frame
|
|
22
|
+
{
|
|
23
|
+
if (self = [super initWithFrame:frame]) {
|
|
24
|
+
static const auto defaultProps = std::make_shared<const PLKEmbeddedViewProps>();
|
|
25
|
+
_props = defaultProps;
|
|
26
|
+
[self prepareView];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return self;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
- (void)prepareView
|
|
33
|
+
{
|
|
34
|
+
_view = [[PLKEmbeddedView alloc] init];
|
|
35
|
+
|
|
36
|
+
__weak __typeof__(self) weakSelf = self;
|
|
37
|
+
|
|
38
|
+
[_view setOnEmbeddedEvent:^(NSDictionary* event) {
|
|
39
|
+
__typeof__(self) strongSelf = weakSelf;
|
|
40
|
+
|
|
41
|
+
if (strongSelf != nullptr && strongSelf->_eventEmitter != nullptr) {
|
|
42
|
+
std::dynamic_pointer_cast<const facebook::react::PLKEmbeddedViewEventEmitter>(strongSelf->_eventEmitter)->onEmbeddedEvent({
|
|
43
|
+
.embeddedEventName = RCTStringFromNSString(event[@"embeddedEventName"]),
|
|
44
|
+
.eventName = RCTStringFromNSString(event[@"eventName"]),
|
|
45
|
+
.error = PLKConvertIdToFollyDynamic(event[@"error"]),
|
|
46
|
+
.publicToken = RCTStringFromNSString(event[@"publicToken"]),
|
|
47
|
+
.metadata = PLKConvertIdToFollyDynamic(event[@"metadata"]),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}];
|
|
51
|
+
self.contentView = _view;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
#pragma mark - RCTComponentViewProtocol
|
|
55
|
+
|
|
56
|
+
+ (ComponentDescriptorProvider)componentDescriptorProvider
|
|
57
|
+
{
|
|
58
|
+
return concreteComponentDescriptorProvider<PLKEmbeddedViewComponentDescriptor>();
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
- (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared &)oldProps
|
|
63
|
+
{
|
|
64
|
+
const auto &newProps = static_cast<const PLKEmbeddedViewProps &>(*props);
|
|
65
|
+
_view.token = RCTNSStringFromStringNilIfEmpty(newProps.token);
|
|
66
|
+
_view.iOSPresentationStyle = RCTNSStringFromStringNilIfEmpty(newProps.token);
|
|
67
|
+
|
|
68
|
+
[super updateProps:props oldProps:oldProps];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
- (void)prepareForRecycle
|
|
72
|
+
{
|
|
73
|
+
[super prepareForRecycle];
|
|
74
|
+
[self prepareView];
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
@end
|
|
79
|
+
|
|
80
|
+
Class<RCTComponentViewProtocol> PLKEmbeddedViewCls(void)
|
|
81
|
+
{
|
|
82
|
+
return PLKEmbeddedViewComponentView.class;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#import <React/RCTConversions.h>
|
|
2
|
+
#import <folly/dynamic.h>
|
|
3
|
+
#import <objc/runtime.h>
|
|
4
|
+
|
|
5
|
+
#if __has_include(<rnplaidlink/react_native_plaid_link_sdk-Swift.h>)
|
|
6
|
+
#import <rnplaidlink/react_native_plaid_link_sdk-Swift.h>
|
|
7
|
+
#else
|
|
8
|
+
#import <react_native_plaid_link_sdk-Swift.h>
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
// copied from RCTFollyConvert
|
|
12
|
+
folly::dynamic PLKConvertIdToFollyDynamic(id json)
|
|
13
|
+
{
|
|
14
|
+
if (json == nil || json == (id)kCFNull) {
|
|
15
|
+
return nullptr;
|
|
16
|
+
} else if ([json isKindOfClass:[NSNumber class]]) {
|
|
17
|
+
const char *objCType = [json objCType];
|
|
18
|
+
switch (objCType[0]) {
|
|
19
|
+
// This is a c++ bool or C99 _Bool. On some platforms, BOOL is a bool.
|
|
20
|
+
case _C_BOOL:
|
|
21
|
+
return (bool)[json boolValue];
|
|
22
|
+
case _C_CHR:
|
|
23
|
+
// On some platforms, objc BOOL is a signed char, but it
|
|
24
|
+
// might also be a small number. Use the same hack JSC uses
|
|
25
|
+
// to distinguish them:
|
|
26
|
+
// https://phabricator.intern.facebook.com/diffusion/FBS/browse/master/fbobjc/xplat/third-party/jsc/safari-600-1-4-17/JavaScriptCore/API/JSValue.mm;b8ee03916489f8b12143cd5c0bca546da5014fc9$901
|
|
27
|
+
if ([json isKindOfClass:[@YES class]]) {
|
|
28
|
+
return (bool)[json boolValue];
|
|
29
|
+
} else {
|
|
30
|
+
return [json longLongValue];
|
|
31
|
+
}
|
|
32
|
+
case _C_UCHR:
|
|
33
|
+
case _C_SHT:
|
|
34
|
+
case _C_USHT:
|
|
35
|
+
case _C_INT:
|
|
36
|
+
case _C_UINT:
|
|
37
|
+
case _C_LNG:
|
|
38
|
+
case _C_ULNG:
|
|
39
|
+
case _C_LNG_LNG:
|
|
40
|
+
case _C_ULNG_LNG:
|
|
41
|
+
return [json longLongValue];
|
|
42
|
+
|
|
43
|
+
case _C_FLT:
|
|
44
|
+
case _C_DBL:
|
|
45
|
+
return [json doubleValue];
|
|
46
|
+
|
|
47
|
+
// default:
|
|
48
|
+
// fall through
|
|
49
|
+
}
|
|
50
|
+
} else if ([json isKindOfClass:[NSString class]]) {
|
|
51
|
+
NSData *data = [json dataUsingEncoding:NSUTF8StringEncoding];
|
|
52
|
+
return std::string(reinterpret_cast<const char *>(data.bytes), data.length);
|
|
53
|
+
} else if ([json isKindOfClass:[NSArray class]]) {
|
|
54
|
+
folly::dynamic array = folly::dynamic::array;
|
|
55
|
+
for (id element in json) {
|
|
56
|
+
array.push_back(PLKConvertIdToFollyDynamic(element));
|
|
57
|
+
}
|
|
58
|
+
return array;
|
|
59
|
+
} else if ([json isKindOfClass:[NSDictionary class]]) {
|
|
60
|
+
__block folly::dynamic object = folly::dynamic::object();
|
|
61
|
+
|
|
62
|
+
[json enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, __unused BOOL *stop) {
|
|
63
|
+
object.insert(PLKConvertIdToFollyDynamic(key), PLKConvertIdToFollyDynamic(value));
|
|
64
|
+
}];
|
|
65
|
+
|
|
66
|
+
return object;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return nil;
|
|
70
|
+
}
|
package/ios/RNLinksdk.h
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
#
|
|
3
|
-
#import <React/RCTBridgeModule.h>
|
|
4
|
-
#import <React/RCTEventEmitter.h>
|
|
5
|
-
#else
|
|
6
|
-
#import "RCTBridgeModule.h"
|
|
7
|
-
#import "RCTEventEmitter.h"
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import <rnplaidlink/rnplaidlink.h>
|
|
8
3
|
#endif
|
|
4
|
+
#import <React/RCTBridge.h>
|
|
5
|
+
#import "RCTEventEmitter.h"
|
|
9
6
|
|
|
10
7
|
#import <LinkKit/LinkKit.h>
|
|
11
8
|
|
|
12
|
-
@interface RNLinksdk : RCTEventEmitter
|
|
9
|
+
@interface RNLinksdk : RCTEventEmitter
|
|
10
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
11
|
+
<NativePlaidLinkModuleiOSSpec>
|
|
12
|
+
#else
|
|
13
|
+
<RCTBridgeModule>
|
|
14
|
+
#endif
|
|
13
15
|
|
|
14
16
|
+ (NSDictionary *)dictionaryFromSuccess:(PLKLinkSuccess *)success;
|
|
15
17
|
+ (NSDictionary *)dictionaryFromEvent:(PLKLinkEvent *)event;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#import "RNLinksdk.h"
|
|
2
|
+
#import "RNPlaidHelper.h"
|
|
2
3
|
|
|
3
4
|
#import <Foundation/Foundation.h>
|
|
4
5
|
#import <LinkKit/LinkKit.h>
|
|
@@ -27,7 +28,7 @@ static NSString* const kRNLinkKitVersionConstant = @"version";
|
|
|
27
28
|
RCT_EXPORT_MODULE();
|
|
28
29
|
|
|
29
30
|
+ (NSString*)sdkVersion {
|
|
30
|
-
return @"11.
|
|
31
|
+
return @"11.9.0"; // SDK_VERSION
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
+ (NSString*)objCBridgeVersion {
|
|
@@ -66,11 +67,11 @@ RCT_EXPORT_MODULE();
|
|
|
66
67
|
self.hasObservers = NO;
|
|
67
68
|
}
|
|
68
69
|
|
|
69
|
-
RCT_EXPORT_METHOD(create:(NSString*)token :(BOOL)noLoadingState) {
|
|
70
|
-
__weak
|
|
70
|
+
RCT_EXPORT_METHOD(create:(NSString*)token noLoadingState:(BOOL)noLoadingState) {
|
|
71
|
+
__weak RNLinksdk *weakSelf = self;
|
|
71
72
|
|
|
72
73
|
void (^onSuccess)(PLKLinkSuccess *) = ^(PLKLinkSuccess *success) {
|
|
73
|
-
|
|
74
|
+
RNLinksdk *strongSelf = weakSelf;
|
|
74
75
|
|
|
75
76
|
if (strongSelf.successCallback) {
|
|
76
77
|
NSDictionary<NSString*, id> *jsMetadata = [RNLinksdk dictionaryFromSuccess:success];
|
|
@@ -80,7 +81,7 @@ RCT_EXPORT_METHOD(create:(NSString*)token :(BOOL)noLoadingState) {
|
|
|
80
81
|
};
|
|
81
82
|
|
|
82
83
|
void (^onExit)(PLKLinkExit *) = ^(PLKLinkExit *exit) {
|
|
83
|
-
|
|
84
|
+
RNLinksdk *strongSelf = weakSelf;
|
|
84
85
|
|
|
85
86
|
if (strongSelf.exitCallback) {
|
|
86
87
|
NSDictionary *exitMetadata = [RNLinksdk dictionaryFromExit:exit];
|
|
@@ -90,11 +91,12 @@ RCT_EXPORT_METHOD(create:(NSString*)token :(BOOL)noLoadingState) {
|
|
|
90
91
|
strongSelf.exitCallback(@[[NSNull null], exitMetadata]);
|
|
91
92
|
}
|
|
92
93
|
strongSelf.exitCallback = nil;
|
|
94
|
+
strongSelf.linkHandler = nil;
|
|
93
95
|
}
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
void (^onEvent)(PLKLinkEvent *) = ^(PLKLinkEvent *event) {
|
|
97
|
-
|
|
99
|
+
RNLinksdk *strongSelf = weakSelf;
|
|
98
100
|
if (strongSelf.hasObservers) {
|
|
99
101
|
NSDictionary *eventDictionary = [RNLinksdk dictionaryFromEvent:event];
|
|
100
102
|
[strongSelf sendEventWithName:kRNLinkKitOnEventEvent
|
|
@@ -105,7 +107,7 @@ RCT_EXPORT_METHOD(create:(NSString*)token :(BOOL)noLoadingState) {
|
|
|
105
107
|
// If we have dismissed Link.
|
|
106
108
|
if (strongSelf.presentingViewController == nil) {
|
|
107
109
|
// Deallocate the handler it's no longer needed.
|
|
108
|
-
|
|
110
|
+
strongSelf.linkHandler = nil;
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
}
|
|
@@ -117,11 +119,11 @@ RCT_EXPORT_METHOD(create:(NSString*)token :(BOOL)noLoadingState) {
|
|
|
117
119
|
config.noLoadingState = noLoadingState;
|
|
118
120
|
|
|
119
121
|
NSError *creationError = nil;
|
|
120
|
-
self.linkHandler = [
|
|
122
|
+
self.linkHandler = [RNPlaidHelper createWithLinkTokenConfiguration:config error:&creationError];
|
|
121
123
|
self.creationError = creationError;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
RCT_EXPORT_METHOD(open:
|
|
126
|
+
RCT_EXPORT_METHOD(open:(BOOL)fullScreen onSuccess:(RCTResponseSenderBlock)onSuccess onExit:(RCTResponseSenderBlock)onExit) {
|
|
125
127
|
if (self.linkHandler) {
|
|
126
128
|
self.successCallback = onSuccess;
|
|
127
129
|
self.exitCallback = onExit;
|
|
@@ -131,7 +133,7 @@ RCT_EXPORT_METHOD(open: (BOOL)fullScreen :(RCTResponseSenderBlock)onSuccess :(RC
|
|
|
131
133
|
// unnecessarily invoked.
|
|
132
134
|
__block bool didPresent = NO;
|
|
133
135
|
|
|
134
|
-
__weak
|
|
136
|
+
__weak RNLinksdk *weakSelf = self;
|
|
135
137
|
void(^presentationHandler)(UIViewController *) = ^(UIViewController *linkViewController) {
|
|
136
138
|
|
|
137
139
|
if (fullScreen) {
|
|
@@ -635,4 +637,12 @@ RCT_EXPORT_METHOD(dismiss) {
|
|
|
635
637
|
};
|
|
636
638
|
}
|
|
637
639
|
|
|
640
|
+
#if RCT_NEW_ARCH_ENABLED
|
|
641
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
642
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
643
|
+
{
|
|
644
|
+
return std::make_shared<facebook::react::NativePlaidLinkModuleiOSSpecJSI>(params);
|
|
645
|
+
}
|
|
646
|
+
#endif
|
|
647
|
+
|
|
638
648
|
@end
|
|
@@ -7,10 +7,12 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
+
7C18CC3F2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C18CC3A2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.mm */; };
|
|
11
|
+
7C18CC402BED4A1C00EE4F18 /* RNLinksdk.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C18CC3D2BED4A1C00EE4F18 /* RNLinksdk.mm */; };
|
|
12
|
+
7C18CC412BED4A1C00EE4F18 /* RNPlaidHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = 7C18CC3E2BED4A1C00EE4F18 /* RNPlaidHelper.m */; };
|
|
10
13
|
7CE0C74E2A8854CE003941EB /* PLKEmbeddedView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0C74D2A8854CE003941EB /* PLKEmbeddedView.swift */; };
|
|
11
14
|
7CE0C7502A8854D8003941EB /* PLKEmbeddedView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0C74F2A8854D8003941EB /* PLKEmbeddedView.m */; };
|
|
12
15
|
7CE0C7542A8862A2003941EB /* PLKEmbeddedViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7CE0C7532A8862A2003941EB /* PLKEmbeddedViewManager.swift */; };
|
|
13
|
-
B3E7B58A1CC2AC0600A0062D /* RNLinksdk.m in Sources */ = {isa = PBXBuildFile; fileRef = B3E7B5891CC2AC0600A0062D /* RNLinksdk.m */; };
|
|
14
16
|
/* End PBXBuildFile section */
|
|
15
17
|
|
|
16
18
|
/* Begin PBXCopyFilesBuildPhase section */
|
|
@@ -27,12 +29,18 @@
|
|
|
27
29
|
|
|
28
30
|
/* Begin PBXFileReference section */
|
|
29
31
|
134814201AA4EA6300B7C361 /* libRNLinksdk.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNLinksdk.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
32
|
+
7C18CC382BED4A1C00EE4F18 /* RNPlaidHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNPlaidHelper.h; sourceTree = "<group>"; };
|
|
33
|
+
7C18CC392BED4A1C00EE4F18 /* react_native_plaid_link_sdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = react_native_plaid_link_sdk.h; sourceTree = "<group>"; };
|
|
34
|
+
7C18CC3A2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PLKEmbeddedViewComponentView.mm; sourceTree = "<group>"; };
|
|
35
|
+
7C18CC3B2BED4A1C00EE4F18 /* PLKFabricHelpers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLKFabricHelpers.h; sourceTree = "<group>"; };
|
|
36
|
+
7C18CC3C2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PLKEmbeddedViewComponentView.h; sourceTree = "<group>"; };
|
|
37
|
+
7C18CC3D2BED4A1C00EE4F18 /* RNLinksdk.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RNLinksdk.mm; sourceTree = "<group>"; };
|
|
38
|
+
7C18CC3E2BED4A1C00EE4F18 /* RNPlaidHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNPlaidHelper.m; sourceTree = "<group>"; };
|
|
30
39
|
7CE0C74C2A8854CE003941EB /* RNLinksdk-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "RNLinksdk-Bridging-Header.h"; sourceTree = "<group>"; };
|
|
31
40
|
7CE0C74D2A8854CE003941EB /* PLKEmbeddedView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PLKEmbeddedView.swift; sourceTree = "<group>"; };
|
|
32
41
|
7CE0C74F2A8854D8003941EB /* PLKEmbeddedView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PLKEmbeddedView.m; sourceTree = "<group>"; };
|
|
33
42
|
7CE0C7532A8862A2003941EB /* PLKEmbeddedViewManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PLKEmbeddedViewManager.swift; sourceTree = "<group>"; };
|
|
34
43
|
B3E7B5881CC2AC0600A0062D /* RNLinksdk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNLinksdk.h; sourceTree = "<group>"; };
|
|
35
|
-
B3E7B5891CC2AC0600A0062D /* RNLinksdk.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNLinksdk.m; sourceTree = "<group>"; };
|
|
36
44
|
/* End PBXFileReference section */
|
|
37
45
|
|
|
38
46
|
/* Begin PBXFrameworksBuildPhase section */
|
|
@@ -61,7 +69,13 @@
|
|
|
61
69
|
7CE0C74D2A8854CE003941EB /* PLKEmbeddedView.swift */,
|
|
62
70
|
7CE0C7532A8862A2003941EB /* PLKEmbeddedViewManager.swift */,
|
|
63
71
|
B3E7B5881CC2AC0600A0062D /* RNLinksdk.h */,
|
|
64
|
-
|
|
72
|
+
7C18CC3C2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.h */,
|
|
73
|
+
7C18CC3A2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.mm */,
|
|
74
|
+
7C18CC3B2BED4A1C00EE4F18 /* PLKFabricHelpers.h */,
|
|
75
|
+
7C18CC392BED4A1C00EE4F18 /* react_native_plaid_link_sdk.h */,
|
|
76
|
+
7C18CC3D2BED4A1C00EE4F18 /* RNLinksdk.mm */,
|
|
77
|
+
7C18CC382BED4A1C00EE4F18 /* RNPlaidHelper.h */,
|
|
78
|
+
7C18CC3E2BED4A1C00EE4F18 /* RNPlaidHelper.m */,
|
|
65
79
|
134814211AA4EA7D00B7C361 /* Products */,
|
|
66
80
|
7CE0C74C2A8854CE003941EB /* RNLinksdk-Bridging-Header.h */,
|
|
67
81
|
);
|
|
@@ -126,9 +140,11 @@
|
|
|
126
140
|
buildActionMask = 2147483647;
|
|
127
141
|
files = (
|
|
128
142
|
7CE0C7502A8854D8003941EB /* PLKEmbeddedView.m in Sources */,
|
|
129
|
-
|
|
143
|
+
7C18CC412BED4A1C00EE4F18 /* RNPlaidHelper.m in Sources */,
|
|
130
144
|
7CE0C7542A8862A2003941EB /* PLKEmbeddedViewManager.swift in Sources */,
|
|
131
145
|
7CE0C74E2A8854CE003941EB /* PLKEmbeddedView.swift in Sources */,
|
|
146
|
+
7C18CC402BED4A1C00EE4F18 /* RNLinksdk.mm in Sources */,
|
|
147
|
+
7C18CC3F2BED4A1C00EE4F18 /* PLKEmbeddedViewComponentView.mm in Sources */,
|
|
132
148
|
);
|
|
133
149
|
runOnlyForDeploymentPostprocessing = 0;
|
|
134
150
|
};
|
|
Binary file
|
package/ios/RNLinksdk.xcworkspace/xcuserdata/dtroupe.xcuserdatad/UserInterfaceState.xcuserstate
CHANGED
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#import "RNPlaidHelper.h"
|
|
2
|
+
|
|
3
|
+
@implementation RNPlaidHelper
|
|
4
|
+
|
|
5
|
+
+ (id <PLKHandler> _Nullable)createWithLinkTokenConfiguration:(PLKLinkTokenConfiguration * _Nonnull)linkTokenConfiguration error:(NSError * _Nullable * _Nullable)error
|
|
6
|
+
{
|
|
7
|
+
return [PLKPlaid createWithLinkTokenConfiguration:linkTokenConfiguration error:error];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
@end
|
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-plaid-link-sdk",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.9.0",
|
|
4
4
|
"description": "React Native Plaid Link SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"react-native": "src/index.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist/**/*",
|
|
9
10
|
"android/**/*",
|
|
10
|
-
"ios",
|
|
11
|
-
"react-native-plaid-link-sdk.podspec"
|
|
11
|
+
"ios/**/*",
|
|
12
|
+
"react-native-plaid-link-sdk.podspec",
|
|
13
|
+
"src/**/*"
|
|
12
14
|
],
|
|
13
15
|
"scripts": {
|
|
14
16
|
"lint": "eslint \"./**/*.{js,jsx}\" --fix",
|
|
@@ -47,7 +49,7 @@
|
|
|
47
49
|
"@react-native-community/eslint-plugin": "^1.1.0",
|
|
48
50
|
"@types/jest": "^26.0.14",
|
|
49
51
|
"@types/react": "^16.14.20",
|
|
50
|
-
"@types/react-native": "^0.
|
|
52
|
+
"@types/react-native": "^0.71.3",
|
|
51
53
|
"@types/react-test-renderer": "^16.9.3",
|
|
52
54
|
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
53
55
|
"@typescript-eslint/parser": "^4.33.0",
|
|
@@ -62,5 +64,13 @@
|
|
|
62
64
|
"react": "18.0.0",
|
|
63
65
|
"react-native": "0.69.9",
|
|
64
66
|
"typescript": "^4.9.5"
|
|
67
|
+
},
|
|
68
|
+
"codegenConfig": {
|
|
69
|
+
"name": "rnplaidlink",
|
|
70
|
+
"type": "all",
|
|
71
|
+
"jsSrcsDir": "./src/fabric",
|
|
72
|
+
"android": {
|
|
73
|
+
"javaPackageName": "com.plaid"
|
|
74
|
+
}
|
|
65
75
|
}
|
|
66
76
|
}
|
|
@@ -2,6 +2,8 @@ require 'json'
|
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
|
|
5
|
+
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
6
|
+
|
|
5
7
|
Pod::Spec.new do |s|
|
|
6
8
|
s.name = package['name']
|
|
7
9
|
s.version = package['version']
|
|
@@ -13,8 +15,18 @@ Pod::Spec.new do |s|
|
|
|
13
15
|
s.platform = :ios, "14.0"
|
|
14
16
|
|
|
15
17
|
s.source = { :git => "https://github.com/plaid/react-native-plaid-link-sdk.git", :tag => "v#{s.version}" }
|
|
16
|
-
s.source_files = "ios
|
|
18
|
+
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
19
|
+
# we need this since Swift generates import for `react_native_plaid_link_sdk/react_native_plaid_link_sdk.h` and we have to fake it
|
|
20
|
+
s.header_dir = "react_native_plaid_link_sdk"
|
|
21
|
+
# we don't want this to be seen by Swift
|
|
22
|
+
s.private_header_files = 'ios/PLKFabricHelpers.h'
|
|
23
|
+
|
|
24
|
+
if fabric_enabled
|
|
25
|
+
install_modules_dependencies(s)
|
|
26
|
+
else
|
|
27
|
+
s.dependency "React-Core"
|
|
28
|
+
end
|
|
17
29
|
|
|
18
30
|
s.dependency 'React-Core'
|
|
19
|
-
s.dependency 'Plaid', '~> 5.
|
|
31
|
+
s.dependency 'Plaid', '~> 5.5.0'
|
|
20
32
|
end
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { StyleProp, ViewStyle } from 'react-native';
|
|
3
|
+
import NativeEmbeddedLinkView from './NativeEmbeddedLinkView';
|
|
4
|
+
import {
|
|
5
|
+
LinkSuccessListener,
|
|
6
|
+
LinkSuccess,
|
|
7
|
+
LinkExitListener,
|
|
8
|
+
LinkExit,
|
|
9
|
+
LinkIOSPresentationStyle,
|
|
10
|
+
LinkOnEventListener,
|
|
11
|
+
LinkEvent,
|
|
12
|
+
LinkEventName,
|
|
13
|
+
LinkEventMetadata,
|
|
14
|
+
LinkError,
|
|
15
|
+
LinkExitMetadata,
|
|
16
|
+
LinkSuccessMetadata,
|
|
17
|
+
} from '../Types';
|
|
18
|
+
|
|
19
|
+
type EmbeddedLinkProps = {
|
|
20
|
+
token: string,
|
|
21
|
+
iOSPresentationStyle: LinkIOSPresentationStyle,
|
|
22
|
+
onEvent: LinkOnEventListener | undefined,
|
|
23
|
+
onSuccess: LinkSuccessListener,
|
|
24
|
+
onExit: LinkExitListener | undefined,
|
|
25
|
+
style: StyleProp<ViewStyle> | undefined,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class EmbeddedEvent implements LinkEvent {
|
|
29
|
+
eventName: LinkEventName;
|
|
30
|
+
metadata: LinkEventMetadata;
|
|
31
|
+
|
|
32
|
+
constructor(event: any) {
|
|
33
|
+
this.eventName = event.eventName
|
|
34
|
+
this.metadata = event.metadata
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class EmbeddedExit implements LinkExit {
|
|
39
|
+
error: LinkError | undefined;
|
|
40
|
+
metadata: LinkExitMetadata;
|
|
41
|
+
|
|
42
|
+
constructor(event: any) {
|
|
43
|
+
this.error = event.error;
|
|
44
|
+
this.metadata = event.metadata;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class EmbeddedSuccess implements LinkSuccess {
|
|
49
|
+
publicToken: string;
|
|
50
|
+
metadata: LinkSuccessMetadata;
|
|
51
|
+
|
|
52
|
+
constructor(event: any) {
|
|
53
|
+
this.publicToken = event.publicToken;
|
|
54
|
+
this.metadata = event.metadata;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const EmbeddedLinkView: React.FC<EmbeddedLinkProps> = (props) => {
|
|
59
|
+
|
|
60
|
+
const {token, iOSPresentationStyle, onEvent, onSuccess, onExit, style} = props;
|
|
61
|
+
|
|
62
|
+
const onEmbeddedEvent = (event: any) => {
|
|
63
|
+
|
|
64
|
+
switch (event.nativeEvent.embeddedEventName) {
|
|
65
|
+
case 'onSuccess': {
|
|
66
|
+
if (!onSuccess) { return; }
|
|
67
|
+
const embeddedSuccess = new EmbeddedSuccess(event.nativeEvent);
|
|
68
|
+
onSuccess(embeddedSuccess);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
case 'onExit': {
|
|
72
|
+
if (!onExit) {return; }
|
|
73
|
+
const embeddedExit = new EmbeddedExit(event.nativeEvent);
|
|
74
|
+
onExit(embeddedExit);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
case 'onEvent': {
|
|
78
|
+
if (!onEvent) { return; }
|
|
79
|
+
const embeddedEvent = new EmbeddedEvent(event.nativeEvent);
|
|
80
|
+
onEvent(embeddedEvent);
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
default: {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return <NativeEmbeddedLinkView
|
|
90
|
+
token={token}
|
|
91
|
+
iOSPresentationStyle={iOSPresentationStyle.toString()}
|
|
92
|
+
onEmbeddedEvent={onEmbeddedEvent}
|
|
93
|
+
style={style}
|
|
94
|
+
/>
|
|
95
|
+
};
|