react-native-plaid-link-sdk 13.0.4 → 13.1.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.
@@ -801,6 +801,21 @@ export interface LinkTokenConfiguration {
801
801
  onLoad?: () => void;
802
802
  }
803
803
 
804
+ /** Configuration for an Identity Verification Link session. */
805
+ export interface IdentityVerificationTokenConfiguration {
806
+ /** The Identity Verification link token created by your server. */
807
+ token: string;
808
+
809
+ /** Called when the Identity Verification flow completes successfully. */
810
+ onSuccess: LinkSuccessListener;
811
+
812
+ /** Called when the user exits the Identity Verification flow. */
813
+ onExit: LinkExitListener;
814
+
815
+ /** Called as the user reaches points in the Identity Verification flow. */
816
+ onEvent: LinkOnEventListener;
817
+ }
818
+
804
819
  export interface LayerTokenConfiguration {
805
820
  /** The link-token your server retrieved from the /link/token/create endpoint. */
806
821
  token: string;
@@ -8,6 +8,7 @@ import {
8
8
  declare class ReactNativePlaidLinkSdkModule extends NativeModule<ReactNativePlaidLinkSdkModuleEvents> {
9
9
  sdkVersion: string;
10
10
  createPlaidLinkSession(token: string): Promise<void>;
11
+ createPlaidIdentityVerificationSession(token: string): Promise<void>;
11
12
  createPlaidLayerSession(token: string): Promise<void>;
12
13
  createPlaidHeadlessSession(token: string): Promise<void>;
13
14
  openLinkSession(fullScreen: boolean): Promise<void>;
package/src/index.ts CHANGED
@@ -6,6 +6,7 @@ import {
6
6
  LinkEventName,
7
7
  LinkSuccess,
8
8
  LinkTokenConfiguration,
9
+ IdentityVerificationTokenConfiguration,
9
10
  PlaidLinkSession,
10
11
  LayerTokenConfiguration,
11
12
  PlaidLayerSession,
@@ -15,6 +16,114 @@ import {
15
16
  } from "./ReactNativePlaidLinkSdk.types";
16
17
  import NativePlaidModule from "./ReactNativePlaidLinkSdkModule";
17
18
 
19
+ const V13_MIGRATION_GUIDE_URL =
20
+ "https://github.com/plaid/react-native-plaid-link-sdk/blob/master/V13_MIGRATION_GUIDE.md";
21
+
22
+ /**
23
+ * Builds a deprecated export for an API removed in v13.
24
+ *
25
+ * The replacement text is single-sourced: it is thrown at runtime and encoded
26
+ * into the returned type, so `tsc` prints the exact v13 replacement instead of
27
+ * suggesting the (incorrect) default import. Keeping one source for both
28
+ * prevents the runtime message and the compiler diagnostic from drifting apart.
29
+ */
30
+ function migrationDiagnostic<Replacement extends string>(
31
+ name: string,
32
+ replacement: Replacement,
33
+ ): { readonly __migration_error__: `Removed in v13. ${Replacement}` } {
34
+ const removed = () => {
35
+ throw new Error(
36
+ `${name} was removed in react-native-plaid-link-sdk v13. ${replacement} See ${V13_MIGRATION_GUIDE_URL}`,
37
+ );
38
+ };
39
+
40
+ return removed as unknown as {
41
+ readonly __migration_error__: `Removed in v13. ${Replacement}`;
42
+ };
43
+ }
44
+
45
+ /**
46
+ * @deprecated Removed in v13. Use `await createPlaidLinkSession(config)`, then
47
+ * call `await session.open()` on the returned session.
48
+ */
49
+ export const create = migrationDiagnostic(
50
+ "create",
51
+ "Use await createPlaidLinkSession(config), then call await session.open() on the returned session.",
52
+ );
53
+
54
+ /**
55
+ * @deprecated Removed in v13. Call `await session.open()` on the session
56
+ * returned by `createPlaidLinkSession(config)`.
57
+ */
58
+ export const open = migrationDiagnostic(
59
+ "open",
60
+ "Call await session.open() on the session returned by createPlaidLinkSession(config). Move onSuccess, onExit, and onEvent callbacks to the create call.",
61
+ );
62
+
63
+ /**
64
+ * @deprecated Removed in v13. Use `PlaidEmbeddedSearchView`.
65
+ */
66
+ export const EmbeddedLinkView = migrationDiagnostic(
67
+ "EmbeddedLinkView",
68
+ "Use PlaidEmbeddedSearchView.",
69
+ );
70
+
71
+ /**
72
+ * @deprecated Removed in v13. Use `await createPlaidLinkSession(config)`, then
73
+ * call `await session.open()` on the returned session.
74
+ */
75
+ export const openLink = migrationDiagnostic(
76
+ "openLink",
77
+ "Use await createPlaidLinkSession(config), then call await session.open() on the returned session.",
78
+ );
79
+
80
+ /**
81
+ * @deprecated Removed in v13. Pass `onEvent` to the create call instead of
82
+ * subscribing separately.
83
+ */
84
+ export const usePlaidEmitter = migrationDiagnostic(
85
+ "usePlaidEmitter",
86
+ "Pass onEvent to createPlaidLinkSession(config) instead of subscribing separately.",
87
+ );
88
+
89
+ /**
90
+ * @deprecated Removed in v13. Call `await session.submit(data)` on the session
91
+ * returned by `createPlaidLayerSession(config)`.
92
+ */
93
+ export const submit = migrationDiagnostic(
94
+ "submit",
95
+ "Call await session.submit(data) on the session returned by createPlaidLayerSession(config).",
96
+ );
97
+
98
+ /**
99
+ * @deprecated Removed in v13. Build your own button and call
100
+ * `await createPlaidLinkSession(config)`, then `await session.open()`.
101
+ */
102
+ export const PlaidLink = migrationDiagnostic(
103
+ "PlaidLink",
104
+ "Build your own button and call await createPlaidLinkSession(config), then await session.open().",
105
+ );
106
+
107
+ /**
108
+ * @deprecated Removed in v13. Each create call resets session state, so no
109
+ * teardown call is needed.
110
+ */
111
+ export const destroy = migrationDiagnostic(
112
+ "destroy",
113
+ "Remove the call. Each create call resets session state, so no teardown is needed.",
114
+ );
115
+
116
+ /**
117
+ * @deprecated Removed in v13 with no replacement.
118
+ */
119
+ export const dismissLink = migrationDiagnostic(
120
+ "dismissLink",
121
+ "Remove the call. There is no programmatic dismiss API in v13.",
122
+ );
123
+
124
+ /** The React Native Plaid Link SDK version reported by the native module. */
125
+ export const sdkVersion = NativePlaidModule.sdkVersion;
126
+
18
127
  type Subscription = ReturnType<typeof NativePlaidModule.addListener>;
19
128
 
20
129
  let successSub: Subscription | null = null;
@@ -97,6 +206,59 @@ export async function createPlaidLinkSession(
97
206
  };
98
207
  }
99
208
 
209
+ /**
210
+ * Creates an Identity Verification session without waiting for an onLoad
211
+ * callback, which Identity Verification flows do not emit.
212
+ */
213
+ export async function createPlaidIdentityVerificationSession(
214
+ config: IdentityVerificationTokenConfiguration,
215
+ ): Promise<PlaidLinkSession> {
216
+ cleanupListeners();
217
+
218
+ successSub = NativePlaidModule.addListener(
219
+ "PlaidLink.onSuccess",
220
+ (success: LinkSuccess) => {
221
+ config.onSuccess(success);
222
+ cleanupListeners({ keepEventListener: true });
223
+ cleanupAfterPostSuccessHandoffWindow();
224
+ },
225
+ );
226
+
227
+ exitSub = NativePlaidModule.addListener(
228
+ "PlaidLink.onExit",
229
+ (exit: LinkExit) => {
230
+ config.onExit(exit);
231
+ cleanupListeners();
232
+ },
233
+ );
234
+
235
+ eventSub = NativePlaidModule.addListener(
236
+ "PlaidLink.onEvent",
237
+ (event: LinkEvent) => {
238
+ config.onEvent(event);
239
+ if (
240
+ postSuccessHandoffCleanupTimeout &&
241
+ event.eventName === LinkEventName.HANDOFF
242
+ ) {
243
+ cleanupListeners();
244
+ }
245
+ },
246
+ );
247
+
248
+ try {
249
+ await NativePlaidModule.createPlaidIdentityVerificationSession(
250
+ config.token,
251
+ );
252
+ } catch (error) {
253
+ cleanupListeners();
254
+ throw error;
255
+ }
256
+
257
+ return {
258
+ open: (fullScreen = false) => NativePlaidModule.openLinkSession(fullScreen),
259
+ };
260
+ }
261
+
100
262
  export async function createPlaidLayerSession(
101
263
  config: LayerTokenConfiguration,
102
264
  ): Promise<PlaidLayerSession> {
@@ -197,5 +359,11 @@ export {
197
359
  PlaidEmbeddedSearchView,
198
360
  type PlaidEmbeddedSearchViewProps,
199
361
  } from "./PlaidEmbeddedSearchView";
200
- export { default } from "./ReactNativePlaidLinkSdkModule";
362
+
363
+ /**
364
+ * @deprecated Use the package's named exports. Use `sdkVersion` to read the SDK
365
+ * version. The default export exposes internal native-module methods and will
366
+ * be removed in the next major version.
367
+ */
368
+ export default NativePlaidModule;
201
369
  export * from "./ReactNativePlaidLinkSdk.types";