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,169 @@
1
+ import ExpoModulesCore
2
+
3
+ internal struct DocuSignInitConfig: Record {
4
+ @Field var integratorKey: String = ""
5
+ @Field var environment: String = "demo"
6
+ @Field var disablePoweredByBranding: Bool = false
7
+ @Field var disableAppearance: Bool = false
8
+ @Field var disableLocationPermission: Bool = false
9
+ }
10
+
11
+ internal struct DocuSignAuthRecord: Record {
12
+ @Field var accessToken: String = ""
13
+ @Field var accountId: String = ""
14
+ @Field var userId: String = ""
15
+ @Field var userName: String = ""
16
+ @Field var email: String = ""
17
+ @Field var host: String = ""
18
+ @Field var expiresIn: Int = 3600
19
+ }
20
+
21
+ internal struct CaptiveSigningRecord: Record {
22
+ @Field var envelopeId: String = ""
23
+ @Field var recipientUserName: String = ""
24
+ @Field var recipientEmail: String = ""
25
+ @Field var recipientClientUserId: String = ""
26
+ }
27
+
28
+ internal struct CaptiveSigningUrlRecord: Record {
29
+ @Field var signingUrl: String = ""
30
+ @Field var envelopeId: String = ""
31
+ @Field var recipientId: String = ""
32
+ }
33
+
34
+ public class DocuSignModule: Module {
35
+ public func definition() -> ModuleDefinition {
36
+ Name("DocuSign")
37
+
38
+ Events("onSigningComplete", "onSigningCancelled", "onSigningError", "onLoginAttempt")
39
+
40
+ OnCreate {
41
+ DocuSignManager.shared.setModule(self)
42
+ }
43
+
44
+ AsyncFunction("initialize") { (config: DocuSignInitConfig, promise: Promise) in
45
+ do {
46
+ let environment = DocuSignEnvironment(rawValue: config.environment) ?? .demo
47
+ let options = DocuSignSetupOptions(
48
+ disablePoweredByBranding: config.disablePoweredByBranding,
49
+ disableAppearance: config.disableAppearance,
50
+ disableLocationPermission: config.disableLocationPermission
51
+ )
52
+ try DocuSignManager.shared.initialize(
53
+ integratorKey: config.integratorKey,
54
+ environment: environment,
55
+ options: options
56
+ )
57
+ promise.resolve(nil)
58
+ } catch {
59
+ promise.reject(error)
60
+ }
61
+ }
62
+
63
+ AsyncFunction("loginWithAccessToken") { (params: DocuSignAuthRecord, promise: Promise) in
64
+ do {
65
+ try DocuSignManager.shared.loginWithAccessToken(
66
+ accessToken: params.accessToken,
67
+ accountId: params.accountId,
68
+ userId: params.userId,
69
+ userName: params.userName,
70
+ email: params.email,
71
+ host: params.host,
72
+ expiresIn: params.expiresIn
73
+ ) { result in
74
+ switch result {
75
+ case .success(let info):
76
+ promise.resolve([
77
+ "accountId": info.accountId,
78
+ "userId": info.userId,
79
+ "userName": info.userName,
80
+ "email": info.email
81
+ ])
82
+ case .failure(let error):
83
+ self.sendEvent("onSigningError", [
84
+ "errorCode": "login_failed",
85
+ "errorMessage": error.localizedDescription
86
+ ])
87
+ promise.reject(LoginFailedException(error.localizedDescription))
88
+ }
89
+ }
90
+ } catch {
91
+ promise.reject(error)
92
+ }
93
+ }
94
+
95
+ AsyncFunction("presentCaptiveSigning") { (params: CaptiveSigningRecord, promise: Promise) in
96
+ do {
97
+ try DocuSignManager.shared.presentCaptiveSigning(
98
+ envelopeId: params.envelopeId,
99
+ recipientUserName: params.recipientUserName,
100
+ recipientEmail: params.recipientEmail,
101
+ recipientClientUserId: params.recipientClientUserId
102
+ ) { result in
103
+ switch result {
104
+ case .success(let outcome):
105
+ promise.resolve([
106
+ "status": outcome.status,
107
+ "envelopeId": outcome.envelopeId,
108
+ "errorCode": outcome.errorCode as Any,
109
+ "errorMessage": outcome.errorMessage as Any
110
+ ])
111
+ case .failure(let error):
112
+ self.sendEvent("onSigningError", [
113
+ "envelopeId": params.envelopeId,
114
+ "errorCode": "signing_failed",
115
+ "errorMessage": error.localizedDescription
116
+ ])
117
+ promise.reject(SigningFailedException(error.localizedDescription))
118
+ }
119
+ }
120
+ } catch {
121
+ promise.reject(error)
122
+ }
123
+ }
124
+
125
+ AsyncFunction("presentCaptiveSigningWithUrl") { (params: CaptiveSigningUrlRecord, promise: Promise) in
126
+ do {
127
+ try DocuSignManager.shared.presentCaptiveSigningWithUrl(
128
+ signingUrl: params.signingUrl,
129
+ envelopeId: params.envelopeId,
130
+ recipientId: params.recipientId.isEmpty ? nil : params.recipientId
131
+ ) { result in
132
+ switch result {
133
+ case .success(let outcome):
134
+ promise.resolve([
135
+ "status": outcome.status,
136
+ "envelopeId": outcome.envelopeId,
137
+ "errorCode": outcome.errorCode as Any,
138
+ "errorMessage": outcome.errorMessage as Any
139
+ ])
140
+ case .failure(let error):
141
+ self.sendEvent("onSigningError", [
142
+ "envelopeId": params.envelopeId,
143
+ "errorCode": "signing_failed",
144
+ "errorMessage": error.localizedDescription
145
+ ])
146
+ promise.reject(SigningFailedException(error.localizedDescription))
147
+ }
148
+ }
149
+ } catch {
150
+ promise.reject(error)
151
+ }
152
+ }
153
+
154
+ AsyncFunction("logout") { (promise: Promise) in
155
+ DocuSignManager.shared.logout()
156
+ promise.resolve(nil)
157
+ }
158
+
159
+ AsyncFunction("isLoggedIn") { (promise: Promise) in
160
+ promise.resolve(DocuSignManager.shared.isLoggedIn())
161
+ }
162
+
163
+ AsyncFunction("endSigningSession") { (promise: Promise) in
164
+ DocuSignManager.shared.endSigningSession {
165
+ promise.resolve(nil)
166
+ }
167
+ }
168
+ }
169
+ }
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, '..', 'package.json')))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = 'ReactNativeDocuSign'
7
+ s.version = package['version']
8
+ s.summary = package['description']
9
+ s.description = package['description']
10
+ s.license = package['license']
11
+ s.author = package['author']
12
+ s.homepage = package['homepage']
13
+ s.platforms = {
14
+ :ios => '15.1'
15
+ }
16
+ s.swift_version = '5.9'
17
+ s.source = { git: '' }
18
+ s.static_framework = true
19
+
20
+ s.dependency 'ExpoModulesCore'
21
+ s.dependency 'DocuSign', '~> 4.1.1'
22
+
23
+ s.pod_target_xcconfig = {
24
+ 'DEFINES_MODULE' => 'YES',
25
+ 'SWIFT_COMPILATION_MODE' => 'wholemodule'
26
+ }
27
+
28
+ s.source_files = "**/*.{h,m,mm,swift,hpp,cpp}"
29
+ end
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "react-native-docusign",
3
+ "version": "1.0.3",
4
+ "description": "React Native / Expo native module wrapping DocuSign iOS and Android SDKs for in-app captive signing",
5
+ "main": "build/index.js",
6
+ "types": "build/index.d.ts",
7
+ "files": [
8
+ "build",
9
+ "ios",
10
+ "android",
11
+ "plugin/build",
12
+ "expo-module.config.json",
13
+ "app.plugin.js",
14
+ "README.md",
15
+ "CHANGELOG.md",
16
+ "LICENSE"
17
+ ],
18
+ "scripts": {
19
+ "build": "tsc -p tsconfig.build.json && tsc -p plugin/tsconfig.build.json",
20
+ "test": "jest",
21
+ "test:coverage": "jest --coverage",
22
+ "prepublishOnly": "npm run build && npm test"
23
+ },
24
+ "keywords": [
25
+ "react-native",
26
+ "expo",
27
+ "expo-module",
28
+ "docusign",
29
+ "esignature",
30
+ "signing",
31
+ "captive-signing",
32
+ "ios",
33
+ "android"
34
+ ],
35
+ "repository": "https://github.com/IronTony/react-native-docusign",
36
+ "bugs": {
37
+ "url": "https://github.com/IronTony/react-native-docusign/issues"
38
+ },
39
+ "author": "IronTony",
40
+ "license": "MIT",
41
+ "homepage": "https://github.com/IronTony/react-native-docusign",
42
+ "devDependencies": {
43
+ "@react-native/jest-preset": "^0.85.2",
44
+ "@testing-library/react-native": "^13.3.3",
45
+ "@types/adm-zip": "^0.5.8",
46
+ "@types/jest": "^29.5.14",
47
+ "@types/node": "^20.19.39",
48
+ "jest": "^29.7.0",
49
+ "jest-expo": "^55.0.17",
50
+ "react-test-renderer": "^19.2.5"
51
+ },
52
+ "peerDependencies": {
53
+ "expo": "*",
54
+ "react": "*",
55
+ "react-native": "*"
56
+ },
57
+ "dependencies": {
58
+ "adm-zip": "^0.5.17"
59
+ }
60
+ }
@@ -0,0 +1,8 @@
1
+ import { ConfigPlugin } from 'expo/config-plugins';
2
+ export type DocuSignPluginProps = {
3
+ cameraPermission?: string;
4
+ photoPermission?: string;
5
+ androidMavenRepo?: string;
6
+ };
7
+ declare const withDocuSign: ConfigPlugin<DocuSignPluginProps | void>;
8
+ export default withDocuSign;
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ const config_plugins_1 = require("expo/config-plugins");
37
+ const crypto = __importStar(require("crypto"));
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const DEFAULT_CAMERA_PERMISSION = 'Allows signing DocuSign documents with your camera and capturing signatures.';
41
+ const DEFAULT_PHOTO_PERMISSION = 'Allows selecting photos to attach to DocuSign documents.';
42
+ const SDK_PDF_VERSION = '2.1.4';
43
+ const SDK_PDF_UPSTREAM_URL = `https://docucdn-a.akamaihd.net/prod/docusignandroidsdk/com/docusign/sdk-pdf/${SDK_PDF_VERSION}/sdk-pdf-${SDK_PDF_VERSION}.aar`;
44
+ // SHA-256 of the upstream `sdk-pdf-2.1.4.aar` as published on DocuSign's CDN.
45
+ // Verified at the time this version of the plugin was cut. Any deviation
46
+ // (CDN tampering, DNS hijack, partial download) causes the plugin to throw
47
+ // rather than write a binary we cannot vouch for. To bump the upstream SDK
48
+ // version, recompute this hash locally:
49
+ // curl -sSL <SDK_PDF_UPSTREAM_URL> | shasum -a 256
50
+ const SDK_PDF_SHA256 = '26eb53effd74d117397fbfd77e46a94786bbbd05fb9318fdbbff389c1a4dcb0a';
51
+ const STRIPPED_AAR_FILENAME = `sdk-pdf-${SDK_PDF_VERSION}-stripped.aar`;
52
+ const GLIDE_GENERATED_CLASS = 'com/bumptech/glide/GeneratedAppGlideModuleImpl.class';
53
+ function sha256Hex(buffer) {
54
+ return crypto.createHash('sha256').update(buffer).digest('hex');
55
+ }
56
+ function isValidAar(filePath) {
57
+ // An AAR is a ZIP. Smoke-test the central directory by attempting to enumerate
58
+ // entries and find classes.jar. Catches zero-byte or truncated cache files.
59
+ try {
60
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
61
+ const AdmZip = require('adm-zip');
62
+ const zip = new AdmZip(filePath);
63
+ return zip.getEntries().some((e) => e.entryName === 'classes.jar');
64
+ }
65
+ catch {
66
+ return false;
67
+ }
68
+ }
69
+ const withDocuSignIos = (config, props) => (0, config_plugins_1.withInfoPlist)(config, (cfg) => {
70
+ cfg.modResults.NSCameraUsageDescription =
71
+ props.cameraPermission ??
72
+ cfg.modResults.NSCameraUsageDescription ??
73
+ DEFAULT_CAMERA_PERMISSION;
74
+ cfg.modResults.NSPhotoLibraryUsageDescription =
75
+ props.photoPermission ??
76
+ cfg.modResults.NSPhotoLibraryUsageDescription ??
77
+ DEFAULT_PHOTO_PERMISSION;
78
+ return cfg;
79
+ });
80
+ const withDocuSignAndroidPermissions = (config) => {
81
+ const permissions = [
82
+ 'android.permission.INTERNET',
83
+ 'android.permission.ACCESS_NETWORK_STATE',
84
+ 'android.permission.CAMERA',
85
+ ];
86
+ return (0, config_plugins_1.withAndroidManifest)(config, (cfg) => {
87
+ permissions.forEach((permission) => {
88
+ config_plugins_1.AndroidConfig.Permissions.addPermission(cfg.modResults, permission);
89
+ });
90
+ return cfg;
91
+ });
92
+ };
93
+ const withDocuSignAndroidMavenRepo = (config, props) => {
94
+ const repo = props.androidMavenRepo ??
95
+ 'https://docucdn-a.akamaihd.net/prod/docusignandroidsdk';
96
+ return (0, config_plugins_1.withProjectBuildGradle)(config, (cfg) => {
97
+ if (cfg.modResults.language !== 'groovy') {
98
+ config_plugins_1.WarningAggregator.addWarningAndroid('react-native-docusign', `android/build.gradle is Kotlin Script (.kts); cannot auto-inject the DocuSign maven repo. Add the following manually inside allprojects.repositories:\n maven("${repo}")`);
99
+ return cfg;
100
+ }
101
+ if (cfg.modResults.contents.includes(repo)) {
102
+ return cfg;
103
+ }
104
+ const mavenBlock = ` maven { url "${repo}" }`;
105
+ const allprojectsRepositoriesRegex = /(allprojects\s*\{[\s\S]*?repositories\s*\{)/;
106
+ if (allprojectsRepositoriesRegex.test(cfg.modResults.contents)) {
107
+ cfg.modResults.contents = cfg.modResults.contents.replace(allprojectsRepositoriesRegex, `$1\n${mavenBlock}`);
108
+ }
109
+ return cfg;
110
+ });
111
+ };
112
+ const FLAT_DIR_MARKER = 'react-native-docusign-stripped-aar-flatdir';
113
+ const withDocuSignAndroidStrippedAarFlatDir = (config) => (0, config_plugins_1.withProjectBuildGradle)(config, (cfg) => {
114
+ if (cfg.modResults.language !== 'groovy') {
115
+ config_plugins_1.WarningAggregator.addWarningAndroid('react-native-docusign', 'android/build.gradle is Kotlin Script (.kts); cannot auto-inject the stripped sdk-pdf flatDir. Add this inside allprojects:\n afterEvaluate {\n rootProject.findProject(":react-native-docusign")?.let { docusignProject ->\n repositories { flatDir { dirs("${docusignProject.projectDir}/libs") } }\n }\n }');
116
+ return cfg;
117
+ }
118
+ if (cfg.modResults.contents.includes(FLAT_DIR_MARKER)) {
119
+ return cfg;
120
+ }
121
+ const flatDirBlock = ` // ${FLAT_DIR_MARKER}: exposes the stripped sdk-pdf AAR bundled with react-native-docusign.
122
+ // The AAR has com.bumptech.glide.GeneratedAppGlideModuleImpl removed to prevent
123
+ // duplicate-class collisions with expo-image and other Glide-based libraries.
124
+ afterEvaluate {
125
+ def docusignProject = rootProject.findProject(':react-native-docusign')
126
+ if (docusignProject != null) {
127
+ repositories {
128
+ flatDir { dirs "\${docusignProject.projectDir}/libs" }
129
+ }
130
+ }
131
+ }`;
132
+ const allprojectsRegex = /(allprojects\s*\{(?:[^{}]|\{[^{}]*\})*)(\n\})/;
133
+ if (allprojectsRegex.test(cfg.modResults.contents)) {
134
+ cfg.modResults.contents = cfg.modResults.contents.replace(allprojectsRegex, `$1\n${flatDirBlock}$2`);
135
+ }
136
+ return cfg;
137
+ });
138
+ /**
139
+ * Downloads the upstream `com.docusign:sdk-pdf:2.1.4` AAR from DocuSign's
140
+ * public Maven repository and strips the pre-generated
141
+ * `com.bumptech.glide.GeneratedAppGlideModuleImpl` class from its
142
+ * `classes.jar`. The stripped artifact is written to
143
+ * `node_modules/react-native-docusign/android/libs/` so the existing flatDir
144
+ * Gradle injection (added by `withDocuSignAndroidStrippedAarFlatDir`) can
145
+ * resolve it at consumer build time.
146
+ *
147
+ * The strip prevents a duplicate-class collision at the consumer's
148
+ * `mergeDexDebug` / `mergeDexRelease` step when the host app also includes
149
+ * any other `@GlideModule`-bearing library (e.g. `expo-image`).
150
+ *
151
+ * The AAR is fetched from DocuSign's official CDN, processed in-memory, and
152
+ * cached locally. The package itself never redistributes any DocuSign
153
+ * binary; consumers fetch it directly from DocuSign at prebuild time.
154
+ */
155
+ async function fetchUpstreamSdkPdfAar() {
156
+ const response = await fetch(SDK_PDF_UPSTREAM_URL);
157
+ if (!response.ok) {
158
+ throw new Error(`[react-native-docusign] Failed to download sdk-pdf-${SDK_PDF_VERSION}.aar from DocuSign Maven (HTTP ${response.status}). URL: ${SDK_PDF_UPSTREAM_URL}`);
159
+ }
160
+ const buffer = Buffer.from(await response.arrayBuffer());
161
+ const actual = sha256Hex(buffer);
162
+ if (actual !== SDK_PDF_SHA256) {
163
+ throw new Error(`[react-native-docusign] SHA-256 mismatch on downloaded sdk-pdf-${SDK_PDF_VERSION}.aar.\n expected: ${SDK_PDF_SHA256}\n actual: ${actual}\nThe upstream binary at ${SDK_PDF_UPSTREAM_URL} does not match the version this plugin was built against. Refusing to write a binary we cannot vouch for. Causes: CDN compromise, DNS hijack, partial download, or DocuSign re-cut the artifact under the same version. If DocuSign re-cut, bump react-native-docusign and update SDK_PDF_SHA256 in plugin/src/index.ts.`);
164
+ }
165
+ return buffer;
166
+ }
167
+ function stripGlideClassFromAar(aarBuffer) {
168
+ // adm-zip is loaded lazily so unit tests that never touch this codepath do
169
+ // not require the dep to be installed.
170
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
171
+ const AdmZip = require('adm-zip');
172
+ const aar = new AdmZip(aarBuffer);
173
+ const classesEntry = aar.getEntry('classes.jar');
174
+ if (!classesEntry) {
175
+ throw new Error(`[react-native-docusign] Upstream sdk-pdf-${SDK_PDF_VERSION}.aar is missing classes.jar. Refusing to write a malformed artifact. The upstream may have changed structure; please file an issue.`);
176
+ }
177
+ const classesJar = new AdmZip(classesEntry.getData());
178
+ if (!classesJar.getEntry(GLIDE_GENERATED_CLASS)) {
179
+ // Already stripped or upstream changed. Either way, write the AAR as-is.
180
+ return aarBuffer;
181
+ }
182
+ classesJar.deleteFile(GLIDE_GENERATED_CLASS);
183
+ aar.updateFile('classes.jar', classesJar.toBuffer());
184
+ return aar.toBuffer();
185
+ }
186
+ const withDocuSignAndroidStripDocusignSdkPdf = (config) => (0, config_plugins_1.withDangerousMod)(config, [
187
+ 'android',
188
+ async (cfg) => {
189
+ // Resolve the installed package's android/libs/ directory so the
190
+ // `flatDir` injection (which references docusignProject.projectDir/libs)
191
+ // finds the stripped AAR.
192
+ let packageRoot;
193
+ try {
194
+ const packageJsonPath = require.resolve('react-native-docusign/package.json', { paths: [cfg.modRequest.projectRoot] });
195
+ packageRoot = path.dirname(packageJsonPath);
196
+ }
197
+ catch {
198
+ config_plugins_1.WarningAggregator.addWarningAndroid('react-native-docusign', 'Could not resolve react-native-docusign package root from the consumer project. Skipping sdk-pdf strip; expect a duplicate-class collision at dex time if the host app uses expo-image or another Glide-based library.');
199
+ return cfg;
200
+ }
201
+ const libsDir = path.join(packageRoot, 'android', 'libs');
202
+ const targetPath = path.join(libsDir, STRIPPED_AAR_FILENAME);
203
+ // Cache check: only reuse the existing artifact if it is non-empty AND
204
+ // its central directory parses as a valid AAR. A zero-byte file or a
205
+ // corrupted partial write from an interrupted prior prebuild gets
206
+ // regenerated rather than poisoning the consumer's build.
207
+ if (fs.existsSync(targetPath)) {
208
+ const stat = fs.statSync(targetPath);
209
+ if (stat.size > 0 && isValidAar(targetPath)) {
210
+ return cfg;
211
+ }
212
+ fs.unlinkSync(targetPath);
213
+ }
214
+ fs.mkdirSync(libsDir, { recursive: true });
215
+ // Hard-fail on any error. A silent WarningAggregator entry would let
216
+ // `expo prebuild` exit 0 and the consumer would only discover the
217
+ // missing AAR hours later as a cryptic dex duplicate-class failure.
218
+ const upstream = await fetchUpstreamSdkPdfAar();
219
+ const stripped = stripGlideClassFromAar(upstream);
220
+ fs.writeFileSync(targetPath, stripped);
221
+ return cfg;
222
+ },
223
+ ]);
224
+ const withDocuSign = (config, props) => {
225
+ const resolvedProps = props ?? {};
226
+ let updated = config;
227
+ updated = withDocuSignIos(updated, resolvedProps);
228
+ updated = withDocuSignAndroidPermissions(updated);
229
+ updated = withDocuSignAndroidMavenRepo(updated, resolvedProps);
230
+ updated = withDocuSignAndroidStripDocusignSdkPdf(updated);
231
+ updated = withDocuSignAndroidStrippedAarFlatDir(updated);
232
+ return updated;
233
+ };
234
+ exports.default = withDocuSign;
235
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sour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