react-native-docusign 1.0.3

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +48 -0
  2. package/LICENSE +21 -0
  3. package/README.md +867 -0
  4. package/android/build.gradle +81 -0
  5. package/android/src/main/AndroidManifest.xml +7 -0
  6. package/android/src/main/java/expo/modules/docusign/DocuSignError.kt +18 -0
  7. package/android/src/main/java/expo/modules/docusign/DocuSignManager.kt +321 -0
  8. package/android/src/main/java/expo/modules/docusign/DocuSignModule.kt +190 -0
  9. package/app.plugin.js +1 -0
  10. package/build/DocuSign.types.d.ts +77 -0
  11. package/build/DocuSign.types.d.ts.map +1 -0
  12. package/build/DocuSign.types.js +2 -0
  13. package/build/DocuSign.types.js.map +1 -0
  14. package/build/DocuSignModule.d.ts +14 -0
  15. package/build/DocuSignModule.d.ts.map +1 -0
  16. package/build/DocuSignModule.js +3 -0
  17. package/build/DocuSignModule.js.map +1 -0
  18. package/build/api.d.ts +39 -0
  19. package/build/api.d.ts.map +1 -0
  20. package/build/api.js +62 -0
  21. package/build/api.js.map +1 -0
  22. package/build/index.d.ts +6 -0
  23. package/build/index.d.ts.map +1 -0
  24. package/build/index.js +5 -0
  25. package/build/index.js.map +1 -0
  26. package/build/useDocuSignSigning.d.ts +38 -0
  27. package/build/useDocuSignSigning.d.ts.map +1 -0
  28. package/build/useDocuSignSigning.js +126 -0
  29. package/build/useDocuSignSigning.js.map +1 -0
  30. package/expo-module.config.json +9 -0
  31. package/ios/DocuSignError.swift +31 -0
  32. package/ios/DocuSignManager.swift +776 -0
  33. package/ios/DocuSignModule.swift +169 -0
  34. package/ios/ReactNativeDocuSign.podspec +29 -0
  35. package/package.json +60 -0
  36. package/plugin/build/index.d.ts +8 -0
  37. package/plugin/build/index.js +235 -0
  38. package/plugin/build/index.js.map +1 -0
@@ -0,0 +1,81 @@
1
+ apply plugin: 'com.android.library'
2
+ apply plugin: 'kotlin-android'
3
+
4
+ group = 'expo.modules.docusign'
5
+ version = '1.0.0'
6
+
7
+ buildscript {
8
+ def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
9
+ if (expoModulesCorePlugin.exists()) {
10
+ apply from: expoModulesCorePlugin
11
+ applyKotlinExpoModulesCorePlugin()
12
+ }
13
+
14
+ ext.safeExtGet = { prop, fallback ->
15
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
16
+ }
17
+
18
+ ext.getKotlinVersion = {
19
+ if (ext.has("kotlinVersion")) {
20
+ ext.kotlinVersion()
21
+ } else {
22
+ ext.safeExtGet("kotlinVersion", "1.8.10")
23
+ }
24
+ }
25
+
26
+ repositories {
27
+ mavenCentral()
28
+ }
29
+
30
+ dependencies {
31
+ classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
32
+ }
33
+ }
34
+
35
+ android {
36
+ compileSdkVersion safeExtGet("compileSdkVersion", 35)
37
+
38
+ namespace "expo.modules.docusign"
39
+
40
+ defaultConfig {
41
+ minSdkVersion safeExtGet("minSdkVersion", 24)
42
+ targetSdkVersion safeExtGet("targetSdkVersion", 35)
43
+ versionCode 1
44
+ versionName "1.0.0"
45
+ }
46
+
47
+ buildFeatures {
48
+ buildConfig = true
49
+ }
50
+
51
+ lintOptions {
52
+ abortOnError false
53
+ }
54
+ }
55
+
56
+ repositories {
57
+ mavenCentral()
58
+ maven {
59
+ url "https://docucdn-a.akamaihd.net/prod/docusignandroidsdk"
60
+ }
61
+ flatDir {
62
+ dirs "$projectDir/libs"
63
+ }
64
+ }
65
+
66
+ dependencies {
67
+ implementation project(':expo-modules-core')
68
+ implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
69
+ implementation 'androidx.appcompat:appcompat:1.6.1'
70
+
71
+ // DocuSign's sdk-pdf AAR ships its own @GlideModule AppGlideModule, which
72
+ // generates com.bumptech.glide.GeneratedAppGlideModuleImpl.class. This
73
+ // collides with expo-image (and any other Glide-based library) at dex time.
74
+ // We exclude the upstream sdk-pdf and link a locally-stripped copy from
75
+ // libs/ that has the generated Glide classes removed.
76
+ implementation('com.docusign:androidsdk:2.1.4') {
77
+ exclude group: 'com.docusign', module: 'sdk-pdf'
78
+ }
79
+ implementation 'com.docusign:sdk-common:2.1.4'
80
+ implementation(name: 'sdk-pdf-2.1.4-stripped', ext: 'aar')
81
+ }
@@ -0,0 +1,7 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <uses-permission android:name="android.permission.INTERNET" />
3
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
4
+ <uses-permission android:name="android.permission.CAMERA" />
5
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
6
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
7
+ </manifest>
@@ -0,0 +1,18 @@
1
+ package expo.modules.docusign
2
+
3
+ import expo.modules.kotlin.exception.CodedException
4
+
5
+ class NotInitializedException :
6
+ CodedException("DocuSign SDK has not been initialized. Call initialize() first.")
7
+
8
+ class NotLoggedInException :
9
+ CodedException("DocuSign SDK is not logged in. Call loginWithAccessToken() first.")
10
+
11
+ class LoginFailedException(message: String) :
12
+ CodedException("DocuSign login failed: $message")
13
+
14
+ class SigningFailedException(message: String) :
15
+ CodedException("DocuSign signing failed: $message")
16
+
17
+ class PresentationException(message: String) :
18
+ CodedException("Failed to present DocuSign signing UI: $message")
@@ -0,0 +1,321 @@
1
+ package expo.modules.docusign
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import com.docusign.androidsdk.DSEnvironment
6
+ import com.docusign.androidsdk.DocuSign
7
+ import com.docusign.androidsdk.dsmodels.DSUser
8
+ import com.docusign.androidsdk.exceptions.DSAuthenticationException
9
+ import com.docusign.androidsdk.exceptions.DSSigningException
10
+ import com.docusign.androidsdk.listeners.DSAuthenticationListener
11
+ import com.docusign.androidsdk.listeners.DSCaptiveSigningListener
12
+ import com.docusign.androidsdk.listeners.DSLogoutListener
13
+ import com.docusign.androidsdk.util.DSMode
14
+ import java.net.HttpURLConnection
15
+ import java.net.URL
16
+ import java.util.concurrent.atomic.AtomicReference
17
+ import kotlin.concurrent.thread
18
+
19
+ internal enum class DocuSignEnvironment(val value: String) {
20
+ DEMO("demo"),
21
+ PRODUCTION("production");
22
+
23
+ companion object {
24
+ fun fromString(value: String): DocuSignEnvironment =
25
+ values().firstOrNull { it.value == value } ?: DEMO
26
+ }
27
+ }
28
+
29
+ internal data class SigningOutcome(
30
+ val status: String,
31
+ val envelopeId: String,
32
+ val errorCode: String? = null,
33
+ val errorMessage: String? = null
34
+ )
35
+
36
+ internal data class DocuSignAccountInfo(
37
+ val accountId: String,
38
+ val userId: String,
39
+ val userName: String,
40
+ val email: String
41
+ )
42
+
43
+ internal object DocuSignManager {
44
+ @Volatile private var isInitialized = false
45
+ @Volatile private var hasLoggedIn = false
46
+ @Volatile private var module: DocuSignModule? = null
47
+ @Volatile private var appContext: Context? = null
48
+ @Volatile private var integratorKey: String = ""
49
+ @Volatile private var environment: DocuSignEnvironment = DocuSignEnvironment.DEMO
50
+ @Volatile private var currentEnvelopeId: String? = null
51
+ private val pendingCompletion = AtomicReference<((Result<SigningOutcome>) -> Unit)?>(null)
52
+
53
+ private enum class UserInfoProbe { OK, UNAUTHORIZED, NETWORK }
54
+
55
+ fun setModule(module: DocuSignModule) {
56
+ this.module = module
57
+ }
58
+
59
+ fun initialize(
60
+ context: Context,
61
+ integratorKey: String,
62
+ environment: DocuSignEnvironment
63
+ ) {
64
+ if (isInitialized) {
65
+ return
66
+ }
67
+
68
+ val dsEnvironment = when (environment) {
69
+ DocuSignEnvironment.DEMO -> DSEnvironment.DEMO_ENVIRONMENT
70
+ DocuSignEnvironment.PRODUCTION -> DSEnvironment.PRODUCTION_ENVIRONMENT
71
+ }
72
+
73
+ val mode = if (BuildConfig.DEBUG) DSMode.DEBUG else DSMode.PRODUCTION
74
+ DocuSign.init(context.applicationContext, integratorKey, "", "", mode)
75
+ .setEnvironment(dsEnvironment)
76
+
77
+ appContext = context.applicationContext
78
+ this.integratorKey = integratorKey
79
+ this.environment = environment
80
+ isInitialized = true
81
+ }
82
+
83
+ fun loginWithAccessToken(
84
+ accessToken: String,
85
+ accountId: String,
86
+ userId: String,
87
+ userName: String,
88
+ email: String,
89
+ host: String,
90
+ expiresIn: Int,
91
+ completion: (Result<DocuSignAccountInfo>) -> Unit
92
+ ) {
93
+ val ctx = appContext
94
+ if (!isInitialized || ctx == null) {
95
+ completion(Result.failure(NotInitializedException()))
96
+ return
97
+ }
98
+
99
+ try {
100
+ DocuSign.getInstance().getAuthenticationDelegate().login(
101
+ accessToken,
102
+ null,
103
+ expiresIn,
104
+ ctx,
105
+ object : DSAuthenticationListener {
106
+ override fun onSuccess(user: DSUser) {
107
+ hasLoggedIn = true
108
+ val info = DocuSignAccountInfo(
109
+ accountId = user.accountId.ifEmpty { accountId },
110
+ userId = user.userId.ifEmpty { userId },
111
+ userName = (user.name ?: "").ifEmpty { userName },
112
+ email = user.email.ifEmpty { email }
113
+ )
114
+ completion(Result.success(info))
115
+ }
116
+
117
+ override fun onError(exception: DSAuthenticationException) {
118
+ val sdkMsg = exception.message ?: "Unknown error"
119
+ classifyLoginFailure(accessToken, sdkMsg) { enrichedMsg ->
120
+ completion(Result.failure(LoginFailedException(enrichedMsg)))
121
+ }
122
+ }
123
+ }
124
+ )
125
+ } catch (e: Exception) {
126
+ completion(Result.failure(LoginFailedException(e.message ?: "Unknown error")))
127
+ }
128
+ }
129
+
130
+ private fun classifyLoginFailure(
131
+ accessToken: String,
132
+ sdkMsg: String,
133
+ completion: (String) -> Unit
134
+ ) {
135
+ probeUserInfoStatus(accessToken) { probe ->
136
+ val diagnostic = "integratorKey=$integratorKey environment=${environment.value}"
137
+ val enriched = when (probe) {
138
+ UserInfoProbe.OK ->
139
+ "SDK rejected a valid token. Likely causes: Mobile SDK not enabled for integration key $integratorKey, or Android package name not whitelisted in DocuSign admin. Contact DocuSign support. (SDK: $sdkMsg) | $diagnostic"
140
+ UserInfoProbe.UNAUTHORIZED ->
141
+ "Access token rejected by DocuSign /oauth/userinfo. Re-mint via JWT Bearer Grant with scope=signature impersonation. (SDK: $sdkMsg) | $diagnostic"
142
+ UserInfoProbe.NETWORK ->
143
+ "$sdkMsg | $diagnostic"
144
+ }
145
+ completion(enriched)
146
+ }
147
+ }
148
+
149
+ private fun probeUserInfoStatus(accessToken: String, completion: (UserInfoProbe) -> Unit) {
150
+ val base = when (environment) {
151
+ DocuSignEnvironment.DEMO -> "https://account-d.docusign.com"
152
+ DocuSignEnvironment.PRODUCTION -> "https://account.docusign.com"
153
+ }
154
+ thread(start = true, isDaemon = true) {
155
+ var connection: HttpURLConnection? = null
156
+ val result = try {
157
+ connection = (URL("$base/oauth/userinfo").openConnection() as HttpURLConnection).apply {
158
+ requestMethod = "GET"
159
+ connectTimeout = 10_000
160
+ readTimeout = 10_000
161
+ setRequestProperty("Authorization", "Bearer $accessToken")
162
+ setRequestProperty("Accept", "application/json")
163
+ }
164
+ when (val code = connection.responseCode) {
165
+ in 200..299 -> UserInfoProbe.OK
166
+ 401, 403 -> UserInfoProbe.UNAUTHORIZED
167
+ else -> {
168
+ android.util.Log.w("DocuSign", "userinfo probe HTTP $code")
169
+ UserInfoProbe.NETWORK
170
+ }
171
+ }
172
+ } catch (e: Exception) {
173
+ android.util.Log.w("DocuSign", "userinfo probe error: ${e.message}")
174
+ UserInfoProbe.NETWORK
175
+ } finally {
176
+ connection?.disconnect()
177
+ }
178
+ completion(result)
179
+ }
180
+ }
181
+
182
+ fun logout() {
183
+ val ctx = appContext
184
+ if (!isInitialized || ctx == null) return
185
+ hasLoggedIn = false
186
+ try {
187
+ DocuSign.getInstance().getAuthenticationDelegate().logout(
188
+ ctx,
189
+ true,
190
+ object : DSLogoutListener {
191
+ override fun onSuccess() {}
192
+ override fun onError(exception: DSAuthenticationException) {}
193
+ }
194
+ )
195
+ } catch (_: Exception) {
196
+ }
197
+ }
198
+
199
+ fun isLoggedIn(): Boolean = hasLoggedIn
200
+
201
+ /**
202
+ * Tears down any in-flight signing session and the underlying SDK auth
203
+ * state so the next `loginWithAccessToken` + `presentCaptiveSigning` pair
204
+ * starts from a clean slate. Safe to call when no session is active.
205
+ *
206
+ * iOS parity: see `DocuSignManager.endSigningSession` in
207
+ * ios/DocuSignManager.swift. The hang this guards against is iOS-only,
208
+ * but exposing the method on both platforms keeps the JS surface
209
+ * symmetric.
210
+ */
211
+ fun endSigningSession() {
212
+ val envelopeId = currentEnvelopeId ?: ""
213
+ currentEnvelopeId = null
214
+ pendingCompletion.getAndSet(null)?.invoke(
215
+ Result.success(
216
+ SigningOutcome(
217
+ status = "cancelled",
218
+ envelopeId = envelopeId,
219
+ errorMessage = "session_ended"
220
+ )
221
+ )
222
+ )
223
+ logout()
224
+ }
225
+
226
+ fun presentCaptiveSigning(
227
+ activity: Activity,
228
+ envelopeId: String,
229
+ recipientUserName: String,
230
+ recipientEmail: String,
231
+ recipientClientUserId: String,
232
+ completion: (Result<SigningOutcome>) -> Unit
233
+ ) {
234
+ if (!isInitialized) {
235
+ completion(Result.failure(NotInitializedException()))
236
+ return
237
+ }
238
+
239
+ if (!isLoggedIn()) {
240
+ completion(Result.failure(NotLoggedInException()))
241
+ return
242
+ }
243
+
244
+ if (!pendingCompletion.compareAndSet(null, completion)) {
245
+ completion(Result.failure(SigningFailedException("A signing session is already in progress")))
246
+ return
247
+ }
248
+ currentEnvelopeId = envelopeId
249
+
250
+ try {
251
+ DocuSign.getInstance().getCustomSettingsDelegate()
252
+ .disableNativeComponentsInOnlineSigning(activity, true)
253
+
254
+ DocuSign.getInstance().getSigningDelegate().launchCaptiveSigning(
255
+ activity,
256
+ envelopeId,
257
+ recipientClientUserId,
258
+ object : DSCaptiveSigningListener {
259
+ override fun onStart(envelopeId: String) {}
260
+
261
+ override fun onSuccess(envelopeId: String) {
262
+ handleSigningCompleted(envelopeId)
263
+ }
264
+
265
+ override fun onCancel(envelopeId: String, recipientId: String) {
266
+ handleSigningCancelled(envelopeId, null)
267
+ }
268
+
269
+ override fun onError(envelopeId: String?, exception: DSSigningException) {
270
+ handleSigningError(
271
+ envelopeId,
272
+ "signing_failed",
273
+ exception.message ?: "Unknown error"
274
+ )
275
+ }
276
+
277
+ override fun onRecipientSigningSuccess(envelopeId: String, recipientId: String) {}
278
+
279
+ override fun onRecipientSigningError(
280
+ envelopeId: String,
281
+ recipientId: String,
282
+ exception: DSSigningException
283
+ ) {
284
+ handleSigningError(
285
+ envelopeId,
286
+ "recipient_signing_failed",
287
+ exception.message ?: "Unknown error"
288
+ )
289
+ }
290
+ }
291
+ )
292
+ } catch (e: Exception) {
293
+ val pending = pendingCompletion.getAndSet(null)
294
+ pending?.invoke(Result.failure(SigningFailedException(e.message ?: "Unknown error")))
295
+ }
296
+ }
297
+
298
+ fun handleSigningCompleted(envelopeId: String) {
299
+ val outcome = SigningOutcome(status = "completed", envelopeId = envelopeId)
300
+ module?.emitSigningComplete(envelopeId)
301
+ currentEnvelopeId = null
302
+ pendingCompletion.getAndSet(null)?.invoke(Result.success(outcome))
303
+ }
304
+
305
+ fun handleSigningCancelled(envelopeId: String, reason: String?) {
306
+ val outcome = SigningOutcome(
307
+ status = "cancelled",
308
+ envelopeId = envelopeId,
309
+ errorMessage = reason
310
+ )
311
+ module?.emitSigningCancelled(envelopeId, reason)
312
+ currentEnvelopeId = null
313
+ pendingCompletion.getAndSet(null)?.invoke(Result.success(outcome))
314
+ }
315
+
316
+ fun handleSigningError(envelopeId: String?, errorCode: String, errorMessage: String) {
317
+ module?.emitSigningError(envelopeId, errorCode, errorMessage)
318
+ currentEnvelopeId = null
319
+ pendingCompletion.getAndSet(null)?.invoke(Result.failure(SigningFailedException(errorMessage)))
320
+ }
321
+ }
@@ -0,0 +1,190 @@
1
+ package expo.modules.docusign
2
+
3
+ import android.app.Activity
4
+ import android.content.Context
5
+ import expo.modules.kotlin.Promise
6
+ import expo.modules.kotlin.exception.Exceptions
7
+ import expo.modules.kotlin.modules.Module
8
+ import expo.modules.kotlin.modules.ModuleDefinition
9
+ import expo.modules.kotlin.records.Field
10
+ import expo.modules.kotlin.records.Record
11
+
12
+ internal class DocuSignInitConfig : Record {
13
+ @Field
14
+ var integratorKey: String = ""
15
+
16
+ @Field
17
+ var environment: String = "demo"
18
+ }
19
+
20
+ internal class DocuSignAuthRecord : Record {
21
+ @Field
22
+ var accessToken: String = ""
23
+
24
+ @Field
25
+ var accountId: String = ""
26
+
27
+ @Field
28
+ var userId: String = ""
29
+
30
+ @Field
31
+ var userName: String = ""
32
+
33
+ @Field
34
+ var email: String = ""
35
+
36
+ @Field
37
+ var host: String = ""
38
+
39
+ @Field
40
+ var expiresIn: Int = 3600
41
+ }
42
+
43
+ internal class CaptiveSigningRecord : Record {
44
+ @Field
45
+ var envelopeId: String = ""
46
+
47
+ @Field
48
+ var recipientUserName: String = ""
49
+
50
+ @Field
51
+ var recipientEmail: String = ""
52
+
53
+ @Field
54
+ var recipientClientUserId: String = ""
55
+ }
56
+
57
+ internal class CaptiveSigningUrlRecord : Record {
58
+ @Field
59
+ var signingUrl: String = ""
60
+
61
+ @Field
62
+ var envelopeId: String = ""
63
+
64
+ @Field
65
+ var recipientId: String = ""
66
+ }
67
+
68
+ class DocuSignModule : Module() {
69
+ override fun definition() = ModuleDefinition {
70
+ val context: Context = appContext.reactContext ?: throw Exceptions.ReactContextLost()
71
+
72
+ Name("DocuSign")
73
+
74
+ Events("onSigningComplete", "onSigningCancelled", "onSigningError")
75
+
76
+ OnCreate {
77
+ DocuSignManager.setModule(this@DocuSignModule)
78
+ }
79
+
80
+ AsyncFunction("initialize") { config: DocuSignInitConfig, promise: Promise ->
81
+ try {
82
+ val environment = DocuSignEnvironment.fromString(config.environment)
83
+ DocuSignManager.initialize(context, config.integratorKey, environment)
84
+ promise.resolve(null)
85
+ } catch (e: Exception) {
86
+ promise.reject("initialize_failed", e.message ?: "Unknown error", e)
87
+ }
88
+ }
89
+
90
+ AsyncFunction("loginWithAccessToken") { params: DocuSignAuthRecord, promise: Promise ->
91
+ DocuSignManager.loginWithAccessToken(
92
+ accessToken = params.accessToken,
93
+ accountId = params.accountId,
94
+ userId = params.userId,
95
+ userName = params.userName,
96
+ email = params.email,
97
+ host = params.host,
98
+ expiresIn = params.expiresIn
99
+ ) { result ->
100
+ result.fold(
101
+ onSuccess = { info ->
102
+ promise.resolve(
103
+ mapOf(
104
+ "accountId" to info.accountId,
105
+ "userId" to info.userId,
106
+ "userName" to info.userName,
107
+ "email" to info.email
108
+ )
109
+ )
110
+ },
111
+ onFailure = { error ->
112
+ emitSigningError(null, "login_failed", error.message ?: "Unknown error")
113
+ promise.reject("login_failed", error.message ?: "Unknown error", error as? Exception)
114
+ }
115
+ )
116
+ }
117
+ }
118
+
119
+ AsyncFunction("presentCaptiveSigning") { params: CaptiveSigningRecord, promise: Promise ->
120
+ val activity: Activity = appContext.activityProvider?.currentActivity
121
+ ?: throw Exceptions.MissingActivity()
122
+
123
+ DocuSignManager.presentCaptiveSigning(
124
+ activity = activity,
125
+ envelopeId = params.envelopeId,
126
+ recipientUserName = params.recipientUserName,
127
+ recipientEmail = params.recipientEmail,
128
+ recipientClientUserId = params.recipientClientUserId
129
+ ) { result ->
130
+ result.fold(
131
+ onSuccess = { outcome ->
132
+ promise.resolve(
133
+ mapOf(
134
+ "status" to outcome.status,
135
+ "envelopeId" to outcome.envelopeId,
136
+ "errorCode" to outcome.errorCode,
137
+ "errorMessage" to outcome.errorMessage
138
+ )
139
+ )
140
+ },
141
+ onFailure = { error ->
142
+ emitSigningError(params.envelopeId, "signing_failed", error.message ?: "Unknown error")
143
+ promise.reject("signing_failed", error.message ?: "Unknown error", error as? Exception)
144
+ }
145
+ )
146
+ }
147
+ }
148
+
149
+ AsyncFunction("presentCaptiveSigningWithUrl") { _: CaptiveSigningUrlRecord, promise: Promise ->
150
+ promise.reject(
151
+ "not_implemented",
152
+ "presentCaptiveSigningWithUrl is iOS-only. On Android, use presentCaptiveSigning after login.",
153
+ UnsupportedOperationException("presentCaptiveSigningWithUrl is iOS-only")
154
+ )
155
+ }
156
+
157
+ AsyncFunction("logout") { promise: Promise ->
158
+ DocuSignManager.logout()
159
+ promise.resolve(null)
160
+ }
161
+
162
+ AsyncFunction("isLoggedIn") { promise: Promise ->
163
+ promise.resolve(DocuSignManager.isLoggedIn())
164
+ }
165
+
166
+ AsyncFunction("endSigningSession") { promise: Promise ->
167
+ DocuSignManager.endSigningSession()
168
+ promise.resolve(null)
169
+ }
170
+ }
171
+
172
+ internal fun emitSigningComplete(envelopeId: String) {
173
+ sendEvent("onSigningComplete", mapOf("envelopeId" to envelopeId))
174
+ }
175
+
176
+ internal fun emitSigningCancelled(envelopeId: String, reason: String?) {
177
+ sendEvent("onSigningCancelled", mapOf("envelopeId" to envelopeId, "reason" to reason))
178
+ }
179
+
180
+ internal fun emitSigningError(envelopeId: String?, errorCode: String, errorMessage: String) {
181
+ sendEvent(
182
+ "onSigningError",
183
+ mapOf(
184
+ "envelopeId" to envelopeId,
185
+ "errorCode" to errorCode,
186
+ "errorMessage" to errorMessage
187
+ )
188
+ )
189
+ }
190
+ }
package/app.plugin.js ADDED
@@ -0,0 +1 @@
1
+ module.exports = require('./plugin/build');
@@ -0,0 +1,77 @@
1
+ export type DocuSignEnvironment = 'demo' | 'production';
2
+ export type DocuSignConfig = {
3
+ integratorKey: string;
4
+ environment: DocuSignEnvironment;
5
+ disablePoweredByBranding?: boolean;
6
+ disableAppearance?: boolean;
7
+ disableLocationPermission?: boolean;
8
+ };
9
+ /**
10
+ * Authentication payload for DocuSign captive signing.
11
+ *
12
+ * If `accountId`, `userId`, `userName`, `email`, or `host` are omitted (or
13
+ * passed as empty strings), the native module performs a single
14
+ * `/oauth/userinfo` lookup against the DocuSign account API using
15
+ * `accessToken` and resolves the missing fields automatically. Pass all five
16
+ * up front to skip the network round-trip on every login.
17
+ */
18
+ export type DocuSignAuthParams = {
19
+ accessToken: string;
20
+ accountId?: string;
21
+ userId?: string;
22
+ userName?: string;
23
+ email?: string;
24
+ host?: string;
25
+ expiresIn?: number;
26
+ };
27
+ export type DocuSignAccountInfo = {
28
+ accountId: string;
29
+ userId: string;
30
+ userName: string;
31
+ email: string;
32
+ };
33
+ export type CaptiveSigningParams = {
34
+ envelopeId: string;
35
+ recipientUserName: string;
36
+ recipientEmail: string;
37
+ recipientClientUserId: string;
38
+ };
39
+ export type CaptiveSigningUrlParams = {
40
+ signingUrl: string;
41
+ envelopeId: string;
42
+ recipientId?: string;
43
+ };
44
+ export type SigningStatus = 'completed' | 'cancelled' | 'error';
45
+ export type SigningResult = {
46
+ status: SigningStatus;
47
+ envelopeId: string;
48
+ errorCode?: string;
49
+ errorMessage?: string;
50
+ };
51
+ export type SigningCompleteEvent = {
52
+ envelopeId: string;
53
+ };
54
+ export type SigningCancelledEvent = {
55
+ envelopeId: string;
56
+ reason?: string;
57
+ };
58
+ export type SigningErrorEvent = {
59
+ envelopeId?: string;
60
+ errorCode: string;
61
+ errorMessage: string;
62
+ };
63
+ export type LoginAttemptEvent = {
64
+ integratorKey: string;
65
+ accountId: string;
66
+ userId: string;
67
+ userName: string;
68
+ email: string;
69
+ host: string;
70
+ };
71
+ export type DocuSignModuleEvents = {
72
+ onSigningComplete: (event: SigningCompleteEvent) => void;
73
+ onSigningCancelled: (event: SigningCancelledEvent) => void;
74
+ onSigningError: (event: SigningErrorEvent) => void;
75
+ onLoginAttempt: (event: LoginAttemptEvent) => void;
76
+ };
77
+ //# sourceMappingURL=DocuSign.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DocuSign.types.d.ts","sourceRoot":"","sources":["../src/DocuSign.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,MAAM,GAAG,YAAY,CAAC;AAExD,MAAM,MAAM,cAAc,GAAG;IAC3B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,mBAAmB,CAAC;IACjC,wBAAwB,C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