react-native-docusign 1.0.3 → 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 +17 -0
- package/README.md +40 -8
- package/android/build.gradle +8 -6
- package/android/src/main/java/expo/modules/docusign/DocuSignManager.kt +28 -0
- package/android/src/main/java/expo/modules/docusign/DocuSignModule.kt +5 -0
- package/build/DocuSignModule.d.ts +1 -0
- package/build/DocuSignModule.d.ts.map +1 -1
- package/build/DocuSignModule.js.map +1 -1
- package/build/api.d.ts +15 -0
- package/build/api.d.ts.map +1 -1
- package/build/api.js +17 -0
- package/build/api.js.map +1 -1
- package/ios/DocuSignManager.swift +98 -33
- package/ios/DocuSignModule.swift +6 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
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
|
+
|
|
9
|
+
## 1.0.4
|
|
10
|
+
|
|
11
|
+
### Bug fixes
|
|
12
|
+
|
|
13
|
+
- **iOS**: Fix endless "we encountered an error, retrying..." loop in the captive signing UI on the second consecutive attempt within the same install. The signing UI registers a service worker on first visit, and `WKWebsiteDataStore.removeData` was being called with an explicit type set that did not include `WKWebsiteDataTypeServiceWorkerRegistrations` or the fetch cache. The stale service worker survived cookie clearing, app force-close, and even SDK-level logout, then intercepted the next signing WebView's fetch calls with stale cached responses. `clearWebCookiesAsync` now passes `WKWebsiteDataStore.allWebsiteDataTypes()`, which wipes service workers, fetch cache, disk cache, and every other WebKit-persisted data type.
|
|
14
|
+
- **iOS**: Always run the WebKit teardown before `DSMManager.login`, including on the first login of a process. The previous "skip teardown when `hasLoggedIn = false`" optimization assumed a fresh process implies fresh WebKit data; that assumption is wrong because `WKWebsiteDataStore` persists across iOS process kills while the in-memory `hasLoggedIn` flag does not. After a force-close, the next login is treated as "first" by the SDK and would skip the wipe, leaving the previous session's service worker behind.
|
|
15
|
+
|
|
16
|
+
### Build / packaging
|
|
17
|
+
|
|
18
|
+
- **Android**: Switch `sdk-pdf-2.1.4-stripped` import from `flatDir`-based `implementation(name: ..., ext: 'aar')` to a direct `implementation files("$projectDir/libs/sdk-pdf-2.1.4-stripped.aar")`. Gradle 9.0 no longer honors subproject-scoped `flatDir` when resolving across project boundaries, so the stripped AAR (placed by the Config Plugin) was not being found and the build failed with `Could not find :sdk-pdf-2.1.4-stripped:`.
|
|
19
|
+
|
|
3
20
|
## 1.0.3
|
|
4
21
|
|
|
5
22
|
### Build / packaging
|
package/README.md
CHANGED
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
|
|
10
10
|
React Native / Expo native module that wraps the official DocuSign iOS and Android SDKs, allowing apps to present the native DocuSign signing UI directly in-app (captive signing).
|
|
11
11
|
|
|
12
|
-
Built on the Expo Modules API. Works with Expo SDK 55
|
|
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
|
|
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)
|
|
@@ -109,7 +110,7 @@ The DocuSign native SDKs are **NOT bundled** inside this npm package. They are d
|
|
|
109
110
|
|
|
110
111
|
### Android Glide collision workaround
|
|
111
112
|
|
|
112
|
-
DocuSign's `com.docusign:sdk-pdf:2.1.4` AAR ships a pre-generated `com.bumptech.glide.GeneratedAppGlideModuleImpl.class` that collides at dex time with any other Glide-based library in the host app (notably `expo-image`, `react-native-fast-image`, and similar). To avoid this without redistributing DocuSign's binary, the Expo Config Plugin downloads `sdk-pdf-2.1.4.aar` directly from DocuSign's public Maven during `expo prebuild`, removes the offending class in-memory, and writes the stripped artifact to `node_modules/react-native-docusign/android/libs/`. The existing flatDir injection picks it up at consumer build time. The download is cached after the first run.
|
|
113
|
+
DocuSign's `com.docusign:sdk-pdf:2.1.4` AAR ships a pre-generated `com.bumptech.glide.GeneratedAppGlideModuleImpl.class` that collides at dex time with any other Glide-based library in the host app (notably `expo-image`, `react-native-fast-image`, and similar). To avoid this without redistributing DocuSign's binary, the Expo Config Plugin downloads `sdk-pdf-2.1.4.aar` directly from DocuSign's public Maven during `expo prebuild`, verifies its SHA-256 against a pinned hash, removes the offending class from the AAR's `classes.jar` in-memory, and writes the stripped artifact to `node_modules/react-native-docusign/android/libs/`. The existing flatDir injection picks it up at consumer build time. The download is cached after the first run; corrupted or partial caches are detected and regenerated. SHA mismatch or fetch failure aborts `expo prebuild` with an actionable error rather than silently letting the Android build fail later at the dex step.
|
|
113
114
|
|
|
114
115
|
### What ships inside this package
|
|
115
116
|
|
|
@@ -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.
|
|
@@ -720,7 +736,7 @@ The module rejects promises with coded exceptions you can inspect at the call si
|
|
|
720
736
|
| Error code | When | Mitigation |
|
|
721
737
|
| ------------------- | --------------------------------------------- | -------------------------------------------------------------- |
|
|
722
738
|
| `initialize_failed` | SDK failed to configure | Check integrator key and network connectivity |
|
|
723
|
-
| `login_failed` | Access token
|
|
739
|
+
| `login_failed` | Access token rejected, or Keychain misconfigured (iOS) | Fetch a fresh token from your backend; on iOS also verify `AppIdentifierPrefix` is set in `Info.plist` (see [Permissions](#permissions)) |
|
|
724
740
|
| `signing_failed` | SDK failed to present or complete signing | Check envelope ID, recipient info, SDK login state |
|
|
725
741
|
| `not_initialized` | `initialize()` was not called first | Call `initialize()` before any other method |
|
|
726
742
|
| `not_logged_in` | `loginWithAccessToken()` was not called first | Call `loginWithAccessToken()` before `presentCaptiveSigning()` |
|
|
@@ -756,10 +772,11 @@ try {
|
|
|
756
772
|
|
|
757
773
|
The config plugin writes these keys automatically, or you can configure them manually:
|
|
758
774
|
|
|
759
|
-
| Key | Purpose
|
|
760
|
-
| -------------------------------- |
|
|
761
|
-
| `NSCameraUsageDescription` | Required when users capture signatures or attach photos via camera
|
|
762
|
-
| `NSPhotoLibraryUsageDescription` | Required when users attach photos from the photo library
|
|
775
|
+
| Key | Purpose |
|
|
776
|
+
| -------------------------------- | -------------------------------------------------------------------------------------------- |
|
|
777
|
+
| `NSCameraUsageDescription` | Required when users capture signatures or attach photos via camera |
|
|
778
|
+
| `NSPhotoLibraryUsageDescription` | Required when users attach photos from the photo library |
|
|
779
|
+
| `AppIdentifierPrefix` | **Required.** Enables the DocuSign iOS SDK to store auth tokens in the Apple Keychain. Without this key, `loginWithAccessToken` fails with `login_failed / unauthorized` even when the token is valid. Set to `$(AppIdentifierPrefix)`; Xcode resolves this to your team ID prefix at build time. |
|
|
763
780
|
|
|
764
781
|
### Android `AndroidManifest.xml`
|
|
765
782
|
|
|
@@ -799,6 +816,21 @@ The SDK login state is in-memory and does not survive app restarts. Always call
|
|
|
799
816
|
|
|
800
817
|
DocuSign access tokens are valid for about 1 hour. If a token expires while the signing UI is open, the SDK emits an error event and the promise rejects. Catch the error, fetch a fresh session from your backend, and retry.
|
|
801
818
|
|
|
819
|
+
### `login_failed` on iOS even with a valid token
|
|
820
|
+
|
|
821
|
+
If `loginWithAccessToken` rejects with `login_failed` (or the SDK logs "unauthorized") but the same token works on Android, the most likely cause is a missing `AppIdentifierPrefix` entry in your `Info.plist`.
|
|
822
|
+
|
|
823
|
+
The DocuSign iOS SDK uses the Apple Keychain to store auth state. Without `AppIdentifierPrefix`, it cannot access the Keychain group and rejects the login at the SDK level, regardless of token validity.
|
|
824
|
+
|
|
825
|
+
**Fix:** add this entry to your `Info.plist` (or to `ios.infoPlist` in `app.config.ts` for Expo projects):
|
|
826
|
+
|
|
827
|
+
```xml
|
|
828
|
+
<key>AppIdentifierPrefix</key>
|
|
829
|
+
<string>$(AppIdentifierPrefix)</string>
|
|
830
|
+
```
|
|
831
|
+
|
|
832
|
+
Xcode resolves `$(AppIdentifierPrefix)` to your Apple Developer team ID prefix at build time. A native rebuild (`expo prebuild` + `expo run:ios`) is required after adding the key.
|
|
833
|
+
|
|
802
834
|
### Signing UI does not appear on iOS
|
|
803
835
|
|
|
804
836
|
The SDK presents its UI on the topmost view controller. If you are presenting from within a modal, the module walks the presented view controller chain. If signing still does not appear, call `presentCaptiveSigning()` after any existing modals have been dismissed.
|
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
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.
|
|
44
|
+
versionName "1.0.5"
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
buildFeatures {
|
|
@@ -58,9 +58,6 @@ repositories {
|
|
|
58
58
|
maven {
|
|
59
59
|
url "https://docucdn-a.akamaihd.net/prod/docusignandroidsdk"
|
|
60
60
|
}
|
|
61
|
-
flatDir {
|
|
62
|
-
dirs "$projectDir/libs"
|
|
63
|
-
}
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
dependencies {
|
|
@@ -77,5 +74,10 @@ dependencies {
|
|
|
77
74
|
exclude group: 'com.docusign', module: 'sdk-pdf'
|
|
78
75
|
}
|
|
79
76
|
implementation 'com.docusign:sdk-common:2.1.4'
|
|
80
|
-
|
|
77
|
+
// Direct file reference instead of flatDir (name:..., ext:...). Gradle 9.0 no
|
|
78
|
+
// longer honors subproject-scoped flatDir when resolving across project
|
|
79
|
+
// boundaries, so the stripped AAR (placed at libs/sdk-pdf-2.1.4-stripped.aar
|
|
80
|
+
// by the config plugin) wasn't found and the build failed with
|
|
81
|
+
// "Could not find :sdk-pdf-2.1.4-stripped:".
|
|
82
|
+
implementation files("$projectDir/libs/sdk-pdf-2.1.4-stripped.aar")
|
|
81
83
|
}
|
|
@@ -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":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAuB,MAAM,MAAM,CAAC;AAEzD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,aAAa,EACd,MAAM,kBAAkB,CAAC;AAE1B,OAAO,OAAO,cAAe,SAAQ,YAAY,CAAC,oBAA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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocuSignModule.js","sourceRoot":"","sources":["../src/DocuSignModule.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,MAAM,MAAM,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;
|
package/build/api.d.ts.map
CHAN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,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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E/C,OAAO,cAAc,CAAC,WAAW,CAAC,mBAAmB,EAAE,QAAQ,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,2BAA2B,CACzC,QAAgD;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"}
|
|
@@ -205,28 +205,17 @@ internal final class DocuSignManager: NSObject {
|
|
|
205
205
|
? Date(timeIntervalSinceNow: TimeInterval(expiresIn))
|
|
206
206
|
: nil
|
|
207
207
|
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
//
|
|
211
|
-
//
|
|
212
|
-
//
|
|
213
|
-
//
|
|
214
|
-
//
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
userId: userId,
|
|
220
|
-
userName: userName,
|
|
221
|
-
email: email,
|
|
222
|
-
effectiveHost: effectiveHost,
|
|
223
|
-
integratorKey: integratorKey,
|
|
224
|
-
expiryDate: expiryDate,
|
|
225
|
-
completion: completion
|
|
226
|
-
)
|
|
227
|
-
return
|
|
228
|
-
}
|
|
229
|
-
|
|
208
|
+
// Always tear down WebKit data + DocuSign auth before DSMManager.login.
|
|
209
|
+
// Earlier versions skipped this on first login (when hasLoggedIn=false) on the
|
|
210
|
+
// assumption that a fresh launch implies fresh WebKit data. That assumption is
|
|
211
|
+
// wrong: WKWebsiteDataStore persists across process kills, so a second launch
|
|
212
|
+
// after a force-close still carries the previous session's WebKit state — most
|
|
213
|
+
// critically, the DocuSign signing UI's service worker registration. Without
|
|
214
|
+
// a wipe, that stale service worker intercepts fetch calls inside the next
|
|
215
|
+
// signing WebView and produces an endless "we encountered an error, retrying..."
|
|
216
|
+
// loop even though the new envelope and tokens are valid. The teardown is
|
|
217
|
+
// sequenced via WKWebsiteDataStore.removeData completion before DSMManager.login
|
|
218
|
+
// is invoked, so there is no race with the WebView session bootstrap.
|
|
230
219
|
clearWebCookiesAsync { [weak self] in
|
|
231
220
|
guard let self = self else { return }
|
|
232
221
|
_ = DSMManager.logout()
|
|
@@ -308,20 +297,31 @@ internal final class DocuSignManager: NSObject {
|
|
|
308
297
|
}
|
|
309
298
|
}
|
|
310
299
|
|
|
311
|
-
/// Clears DocuSign SDK cookies plus
|
|
312
|
-
///
|
|
313
|
-
///
|
|
314
|
-
///
|
|
315
|
-
///
|
|
300
|
+
/// Clears DocuSign SDK cookies plus all WKWebsiteDataStore data and invokes
|
|
301
|
+
/// `completion` on the main thread once teardown is complete. The DocuSign SDK's
|
|
302
|
+
/// `clearAllWebCookies` has no completion handler, so we layer
|
|
303
|
+
/// `WKWebsiteDataStore.removeData` on top to obtain a real signal that teardown
|
|
304
|
+
/// finished before re-logging in.
|
|
305
|
+
///
|
|
306
|
+
/// We pass `WKWebsiteDataStore.allWebsiteDataTypes()` rather than an explicit
|
|
307
|
+
/// subset because the DocuSign signing UI registers a service worker on first
|
|
308
|
+
/// visit, and service worker registrations + the fetch cache are stored
|
|
309
|
+
/// separately from cookies/localStorage/IndexedDB. Clearing only the common
|
|
310
|
+
/// subset leaves the SW behind on disk, which then intercepts the next signing
|
|
311
|
+
/// WebView's fetch calls with stale cached responses.
|
|
312
|
+
///
|
|
313
|
+
/// Note: this wipes the **default** `WKWebsiteDataStore`, which is shared by
|
|
314
|
+
/// every WKWebView in the host process that does not specify a private or
|
|
315
|
+
/// non-persistent configuration. Host apps that use WKWebView for other
|
|
316
|
+
/// content (OAuth flows, in-app browsers, help centers) will have those
|
|
317
|
+
/// WebViews' cookies, caches, and service workers cleared whenever
|
|
318
|
+
/// `loginWithAccessToken` runs. If you need to isolate DocuSign's WebKit
|
|
319
|
+
/// state from the rest of your app, use a non-default data store for those
|
|
320
|
+
/// other WebViews.
|
|
316
321
|
private func clearWebCookiesAsync(completion: @escaping () -> Void) {
|
|
317
322
|
DSMManager.clearAllWebCookies()
|
|
318
323
|
let dataStore = WKWebsiteDataStore.default()
|
|
319
|
-
let types
|
|
320
|
-
WKWebsiteDataTypeCookies,
|
|
321
|
-
WKWebsiteDataTypeSessionStorage,
|
|
322
|
-
WKWebsiteDataTypeLocalStorage,
|
|
323
|
-
WKWebsiteDataTypeIndexedDBDatabases
|
|
324
|
-
]
|
|
324
|
+
let types = WKWebsiteDataStore.allWebsiteDataTypes()
|
|
325
325
|
let since = Date(timeIntervalSince1970: 0)
|
|
326
326
|
dataStore.removeData(ofTypes: types, modifiedSince: since) {
|
|
327
327
|
DispatchQueue.main.async { completion() }
|
|
@@ -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,
|
package/ios/DocuSignModule.swift
CHANGED
package/package.json
CHANGED