react-native-docusign 1.0.4 → 1.0.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.5
4
+
5
+ ### New features
6
+
7
+ - New `reset()` API on iOS and Android. Heavier counterpart to `endSigningSession`: resolves any in-flight signing promise as cancelled, wipes WebKit data on iOS (cookies, service workers, fetch cache, IndexedDB, etc.), calls `logout()`, removes notification observers, and flips the internal `isInitialized` flag to `false` so the next `initialize()` call re-runs the underlying SDK setup against a fresh state. Use it for hard resets (error recovery, switching DocuSign accounts, app-level logout). For routine per-flow teardown on the same auth, prefer `endSigningSession`, which keeps the SDK initialized and avoids the observer churn.
8
+
3
9
  ## 1.0.4
4
10
 
5
11
  ### Bug fixes
package/README.md CHANGED
@@ -11,7 +11,7 @@ React Native / Expo native module that wraps the official DocuSign iOS and Andro
11
11
 
12
12
  Built on the Expo Modules API. Works with Expo SDK 55+ (managed or bare with `expo prebuild`) and Expo Dev Client. Also usable in non-Expo React Native projects after running [`npx install-expo-modules`](https://docs.expo.dev/bare/installing-expo-modules/) to install `expo-modules-core`; in that case, run `expo prebuild` so the Config Plugin can fetch the DocuSign sdk-pdf AAR and inject the iOS / Android build settings, otherwise you must replicate those steps by hand.
13
13
 
14
- > **Unofficial package.** This is a community wrapper. It is not affiliated with or endorsed by DocuSign, Inc. "DocuSign" is a trademark of DocuSign, Inc.
14
+ > **Unofficial package.** This is a community wrapper. It is not affiliated with, endorsed by, or sponsored by DocuSign, Inc. or any other organization. "DocuSign" is a trademark of DocuSign, Inc. The MIT license covers this wrapper's source code only. Consumers are responsible for accepting DocuSign's Mobile SDK License Agreement separately when integrating with DocuSign's services.
15
15
 
16
16
  ## iOS ↔ Android parity
17
17
 
@@ -49,6 +49,7 @@ Full schema and BFF reference implementation: [`docs/BACKEND_GUIDE.md` → Sessi
49
49
  - [logout](#logout-promisevoid)
50
50
  - [isLoggedIn](#isloggedin-promiseboolean)
51
51
  - [endSigningSession](#endsigningsession-promisevoid)
52
+ - [reset](#reset-promisevoid)
52
53
  - [Event listeners](#event-listeners)
53
54
  - [Types](#types)
54
55
  - [Authentication flow](#authentication-flow)
@@ -391,6 +392,21 @@ Call this between captive signing flows (e.g. inside the `finally` block of your
391
392
 
392
393
  The `useDocuSignSigning` hook's `reset()` calls this automatically when the SDK has been initialized.
393
394
 
395
+ ### `reset(): Promise<void>`
396
+
397
+ Full SDK teardown. Heavier counterpart to `endSigningSession`: resolves any in-flight signing promise as cancelled, wipes WebKit data on iOS (cookies, service workers, fetch cache, IndexedDB, etc.), calls `logout()`, removes notification observers (iOS), and flips the internal `isInitialized` flag to `false` so the next `initialize()` call re-runs the underlying SDK setup against a fresh state.
398
+
399
+ Use this when you want a hard reset between flows (error recovery, switching DocuSign accounts, after an app-level logout). For routine teardown between consecutive captive signing flows on the same auth, prefer `endSigningSession`, which keeps the SDK initialized and skips the observer churn.
400
+
401
+ Safe to call when the SDK was never initialized: returns immediately without touching the underlying SDK.
402
+
403
+ | Use case | Recommended call |
404
+ | --- | --- |
405
+ | Between captive signing flows in the same app session | `endSigningSession` |
406
+ | After an error you want to recover from | `reset` |
407
+ | Switching DocuSign accounts / integrator keys | `reset` |
408
+ | App-level logout | `reset` |
409
+
394
410
  ### Event listeners
395
411
 
396
412
  In addition to the promise-based API, you can subscribe to events. Events fire for every signing result, including those triggered from other parts of your app.
@@ -2,7 +2,7 @@ apply plugin: 'com.android.library'
2
2
  apply plugin: 'kotlin-android'
3
3
 
4
4
  group = 'expo.modules.docusign'
5
- version = '1.0.4'
5
+ version = '1.0.5'
6
6
 
7
7
  buildscript {
8
8
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -41,7 +41,7 @@ android {
41
41
  minSdkVersion safeExtGet("minSdkVersion", 24)
42
42
  targetSdkVersion safeExtGet("targetSdkVersion", 35)
43
43
  versionCode 1
44
- versionName "1.0.4"
44
+ versionName "1.0.5"
45
45
  }
46
46
 
47
47
  buildFeatures {
@@ -223,6 +223,34 @@ internal object DocuSignManager {
223
223
  logout()
224
224
  }
225
225
 
226
+ /**
227
+ * Full SDK teardown. Resolves any in-flight signing promise as cancelled,
228
+ * calls `logout()`, and flips `isInitialized` back to `false` so the next
229
+ * `initialize()` call runs `DocuSign.init(...)` against a fresh state.
230
+ *
231
+ * Use this when you want a hard reset between flows (error recovery,
232
+ * switching DocuSign accounts, app-level logout). For routine teardown
233
+ * between consecutive captive signing flows on the same auth, prefer
234
+ * `endSigningSession`.
235
+ *
236
+ * Safe to call when the SDK was never initialized.
237
+ */
238
+ fun reset() {
239
+ val envelopeId = currentEnvelopeId ?: ""
240
+ currentEnvelopeId = null
241
+ pendingCompletion.getAndSet(null)?.invoke(
242
+ Result.success(
243
+ SigningOutcome(
244
+ status = "cancelled",
245
+ envelopeId = envelopeId,
246
+ errorMessage = "reset"
247
+ )
248
+ )
249
+ )
250
+ logout()
251
+ isInitialized = false
252
+ }
253
+
226
254
  fun presentCaptiveSigning(
227
255
  activity: Activity,
228
256
  envelopeId: String,
@@ -167,6 +167,11 @@ class DocuSignModule : Module() {
167
167
  DocuSignManager.endSigningSession()
168
168
  promise.resolve(null)
169
169
  }
170
+
171
+ AsyncFunction("reset") { promise: Promise ->
172
+ DocuSignManager.reset()
173
+ promise.resolve(null)
174
+ }
170
175
  }
171
176
 
172
177
  internal fun emitSigningComplete(envelopeId: String) {
@@ -8,6 +8,7 @@ declare class DocuSignModule extends NativeModule<DocuSignModuleEvents> {
8
8
  logout(): Promise<void>;
9
9
  isLoggedIn(): Promise<boolean>;
10
10
  endSigningSession(): Promise<void>;
11
+ reset(): Promise<void>;
11
12
  }
12
13
  declare const _default: DocuSignModule;
13
14
  export default _default;
@@ -1 +1 @@
1
- {"version":3,"file":"DocuSignModule.d.ts","sourceRoot":"","sources":["../src/DocuSignModule.ts"],"names":[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4B,CAC1B,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,aAAa,CAAC;IACzB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IACvB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;IAC9B,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAClC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CACvB;;AAED,wBAA+D"}
@@ -1 +1 @@
1
- {"version":3,"file":"DocuSignModule.js","sourceRoot":"","sources":["../src/DocuSignModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA0BzD,eAAe,mBAAmB,CAAiB,UAAU,CAAC,CAAC"}
1
+ {"version":3,"file":"DocuSignModule.js","sourceRoot":"","sources":["../src/DocuSignModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,CAAC;AA2BzD,eAAe,mBAAmB,CAAiB,UAAU,CAAC,CAAC"}
package/build/api.d.ts CHANGED
@@ -32,6 +32,21 @@ export declare function isLoggedIn(): Promise<boolean>;
32
32
  * calls this from `reset()` automatically.
33
33
  */
34
34
  export declare function endSigningSession(): Promise<void>;
35
+ /**
36
+ * Full SDK teardown. Resolves any in-flight signing promise as cancelled,
37
+ * wipes WebKit data (iOS), calls `logout()`, removes notification observers
38
+ * (iOS), and flips the internal `isInitialized` flag to `false` so the next
39
+ * `initialize()` call re-runs the underlying SDK setup against a fresh state.
40
+ *
41
+ * Use this when you want a hard reset between flows (error recovery,
42
+ * switching DocuSign accounts, after an app-level logout). For routine
43
+ * teardown between consecutive captive signing flows on the same auth,
44
+ * prefer {@link endSigningSession} which keeps the SDK initialized and
45
+ * skips the observer churn.
46
+ *
47
+ * Safe to call when the SDK was never initialized: returns immediately.
48
+ */
49
+ export declare function reset(): Promise<void>;
35
50
  export declare function addSigningCompleteListener(listener: (event: SigningCompleteEvent) => void): DocuSignSubscription;
36
51
  export declare function addSigningCancelledListener(listener: (event: SigningCancelledEvent) => void): DocuSignSubscription;
37
52
  export declare function addSigningErrorListener(listener: (event: SigningErrorEvent) => void): DocuSignSubscription;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,aAAa,EACd,MAAM,kBAAkB,CAAC;AAG1B,MAAM,MAAM,oBAAoB,GAAG;IACjC,MAAM,IAAI,IAAI,CAAC;CAChB,CAAC;AAEF,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,aAAa,CAAC,CAExB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAC1C,MAAM,EAAE,uBAAuB,GAC9B,OAAO,CAAC,aAAa,CAAC,CASxB;AAED,wBAAgB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAEtC;AAED,wBAAgB,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC,CAE7C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAEjD;AAED,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,GAC9C,oBAAoB,CAEtB;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAC/C,oBAAoB,CAEtB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EA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BAAgB,2BAA2B,CACzC,QAAQ,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,GAC/C,oBAAoB,CAEtB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAC3C,oBAAoB,CAEtB;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,IAAI,GAC3C,oBAAoB,CAEtB"}
package/build/api.js CHANGED
@@ -47,6 +47,23 @@ export function isLoggedIn() {
47
47
  export function endSigningSession() {
48
48
  return DocuSignModule.endSigningSession();
49
49
  }
50
+ /**
51
+ * Full SDK teardown. Resolves any in-flight signing promise as cancelled,
52
+ * wipes WebKit data (iOS), calls `logout()`, removes notification observers
53
+ * (iOS), and flips the internal `isInitialized` flag to `false` so the next
54
+ * `initialize()` call re-runs the underlying SDK setup against a fresh state.
55
+ *
56
+ * Use this when you want a hard reset between flows (error recovery,
57
+ * switching DocuSign accounts, after an app-level logout). For routine
58
+ * teardown between consecutive captive signing flows on the same auth,
59
+ * prefer {@link endSigningSession} which keeps the SDK initialized and
60
+ * skips the observer churn.
61
+ *
62
+ * Safe to call when the SDK was never initialized: returns immediately.
63
+ */
64
+ export function reset() {
65
+ return DocuSignModule.reset();
66
+ }
50
67
  export function addSigningCompleteListener(listener) {
51
68
  return DocuSignModule.addListener('onSigningComplete', listener);
52
69
  }
package/build/api.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAcxC,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAM9C,MAAM,UAAU,UAAU,CAAC,MAAsB;IAC/C,OAAO,cAAc,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAA0B;IAE1B,OAA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AAgD;IAEhD,OAAO,cAAc,CAAC,WAAW,CAAC,oBAAoB,EAAE,QAAQ,CAAC,CAAC;AACpE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,QAA4C;IAE5C,OAAO,cAAc,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,QAA4C;IAE5C,OAAO,cAAc,CAAC,WAAW,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;AAChE,CAAC"}
@@ -554,6 +554,71 @@ internal final class DocuSignManager: NSObject {
554
554
  }
555
555
  }
556
556
 
557
+ /// Full SDK teardown: a heavier counterpart to `endSigningSession`. Resolves
558
+ /// any in-flight signing promise as `cancelled`, wipes WebKit data (cookies,
559
+ /// service workers, fetch cache, etc.), calls `DSMManager.logout()`, removes
560
+ /// notification observers, and resets every internal state flag including
561
+ /// `_isInitialized` and `_observersRegistered`. The next `initialize()` call
562
+ /// will run `DSMManager.setup(withConfiguration:)` again, giving the SDK a
563
+ /// completely fresh slate.
564
+ ///
565
+ /// Use this when you want a hard reset between flows (e.g. error recovery,
566
+ /// switching DocuSign accounts, or after an app-level logout). For routine
567
+ /// teardown between consecutive captive signing flows on the same auth,
568
+ /// prefer `endSigningSession`, which keeps the SDK initialized and skips
569
+ /// the observer churn.
570
+ ///
571
+ /// Safe to call when the SDK was never initialized: returns immediately
572
+ /// without touching DSMManager.
573
+ func reset(completion: @escaping () -> Void) {
574
+ stateQueue.sync {
575
+ if let pending = pendingCompletion {
576
+ let outcome = SigningOutcome(
577
+ status: "cancelled",
578
+ envelopeId: currentEnvelopeId ?? "",
579
+ errorCode: nil,
580
+ errorMessage: "reset"
581
+ )
582
+ pendingCompletion = nil
583
+ currentEnvelopeId = nil
584
+ DispatchQueue.main.async { pending(.success(outcome)) }
585
+ }
586
+ }
587
+
588
+ let needsTeardown = stateQueue.sync { _isInitialized || _hasLoggedIn }
589
+ guard needsTeardown else {
590
+ completion()
591
+ return
592
+ }
593
+
594
+ if !Thread.isMainThread {
595
+ DispatchQueue.main.async { [weak self] in
596
+ guard let self = self else { completion(); return }
597
+ self.reset(completion: completion)
598
+ }
599
+ return
600
+ }
601
+
602
+ clearWebCookiesAsync { [weak self] in
603
+ guard let self = self else { completion(); return }
604
+ _ = DSMManager.logout()
605
+ NotificationCenter.default.removeObserver(self)
606
+ // Use stateQueue.async (not sync) for the state reset. We are on main
607
+ // here (clearWebCookiesAsync's completion is dispatched on main), and a
608
+ // nested stateQueue.sync from main while another thread holds the queue
609
+ // is the classic deadlock recipe. async serializes the writes safely
610
+ // without blocking, then hops back to main to fire the completion.
611
+ self.stateQueue.async {
612
+ self._isInitialized = false
613
+ self._hasLoggedIn = false
614
+ self._integratorKey = nil
615
+ self._hostURL = nil
616
+ self._observersRegistered = false
617
+ DispatchQueue.main.async { completion() }
618
+ }
619
+ }
620
+ }
621
+
557
622
  func presentCaptiveSigning(
558
623
  envelopeId: String,
559
624
  recipientUserName: String,
@@ -165,5 +165,11 @@ public class DocuSignModule: Module {
165
165
  promise.resolve(nil)
166
166
  }
167
167
  }
168
+
169
+ AsyncFunction("reset") { (promise: Promise) in
170
+ DocuSignManager.shared.reset {
171
+ promise.resolve(nil)
172
+ }
173
+ }
168
174
  }
169
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-docusign",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "React Native / Expo native module wrapping DocuSign iOS and Android SDKs for in-app captive signing",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",