@finos_sdk/sdk-ekyc 1.2.2 → 1.2.9
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/LICENSE +13 -10
- package/README.md +41 -42
- package/android/build.gradle +42 -11
- package/android/gradle.properties +7 -1
- package/android/settings.gradle +53 -0
- package/android/src/main/java/finos/sdk/ekyc/EKYCModule.kt +791 -81
- package/dist/EKYCModule.d.ts +73 -0
- package/dist/EKYCModule.js +663 -71
- package/dist/index.d.ts +6 -1
- package/dist/index.js +5 -1
- package/dist/package.json +31 -21
- package/dist/src/modules/FinosEKYCModule.d.ts +149 -0
- package/dist/src/modules/FinosEKYCModule.js +485 -2
- package/dist/src/modules/FinosESignModule.d.ts +270 -0
- package/dist/src/modules/FinosESignModule.js +752 -0
- package/dist/src/types/ekycESignType.d.ts +67 -0
- package/dist/src/types/ekycESignType.js +2 -0
- package/dist/src/types/ekycSmsOtpType.d.ts +52 -0
- package/dist/src/types/ekycSmsOtpType.js +2 -0
- package/package.json +31 -21
- package/src/modules/FinosEKYCModule.ts +572 -2
- package/src/modules/FinosESignModule.ts +919 -0
- package/src/modules/README.md +3 -3
- package/src/types/ekycESignType.ts +76 -0
- package/src/types/ekycSmsOtpType.ts +59 -0
- package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.module +0 -110
- package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.pom +0 -37
- package/android/SDKeKYC/finos/sdk/ekyc/c06/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.module +0 -201
- package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.pom +0 -73
- package/android/SDKeKYC/finos/sdk/ekyc/ekyc/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.module +0 -131
- package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.pom +0 -43
- package/android/SDKeKYC/finos/sdk/ekyc/ekycui/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.module +0 -110
- package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.pom +0 -37
- package/android/SDKeKYC/finos/sdk/ekyc/faceservice/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.module +0 -138
- package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.pom +0 -55
- package/android/SDKeKYC/finos/sdk/ekyc/liveness/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.module +0 -131
- package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.pom +0 -55
- package/android/SDKeKYC/finos/sdk/ekyc/nfc/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.module +0 -124
- package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.pom +0 -43
- package/android/SDKeKYC/finos/sdk/ekyc/ocr/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.module +0 -138
- package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.pom +0 -55
- package/android/SDKeKYC/finos/sdk/ekyc/qrcode/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.module +0 -341
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.pom +0 -139
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.module +0 -201
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.pom +0 -85
- package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/maven-metadata-local.xml +0 -13
- package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2-sources.jar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.aar +0 -0
- package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.module +0 -208
- package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.pom +0 -103
- package/android/SDKeKYC/finos/sdk/ekyc/sdkui/maven-metadata-local.xml +0 -13
- package/android/src/main/AndroidManifest.xml +0 -22
- package/android/src/main/build.gradle +0 -31
- package/dist/App.d.ts +0 -3
- package/dist/App.js +0 -497
- package/dist/finos_sdk-sdk-ekyc-1.2.2.tgz +0 -0
|
@@ -0,0 +1,752 @@
|
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.SDK_NAME = exports.SDK_VERSION = exports.FinosESign = exports.FinosESignModule = void 0;
|
|
27
|
+
const react_native_1 = require("react-native");
|
|
28
|
+
const EKYCModule_1 = __importStar(require("../../EKYCModule"));
|
|
29
|
+
Object.defineProperty(exports, "SDK_VERSION", { enumerable: true, get: function () { return EKYCModule_1.SDK_VERSION; } });
|
|
30
|
+
Object.defineProperty(exports, "SDK_NAME", { enumerable: true, get: function () { return EKYCModule_1.SDK_NAME; } });
|
|
31
|
+
/**
|
|
32
|
+
* Finos eSign SDK Module
|
|
33
|
+
*
|
|
34
|
+
* A React Native module for eSign (Electronic Signature), SMS OTP, Liveness detection,
|
|
35
|
+
* and Face matching operations. This module excludes NFC, C06, and OCR features.
|
|
36
|
+
*
|
|
37
|
+
* @version Dynamic from package.json
|
|
38
|
+
* @author FinOS
|
|
39
|
+
* @license MIT
|
|
40
|
+
*/
|
|
41
|
+
class FinosESignModule {
|
|
42
|
+
constructor() {
|
|
43
|
+
this.isInitialized = false;
|
|
44
|
+
this.sdk = EKYCModule_1.default;
|
|
45
|
+
this.platform = react_native_1.Platform.OS;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Get singleton instance of FinosESignModule
|
|
49
|
+
*/
|
|
50
|
+
static getInstance() {
|
|
51
|
+
if (!FinosESignModule.instance) {
|
|
52
|
+
FinosESignModule.instance = new FinosESignModule();
|
|
53
|
+
}
|
|
54
|
+
return FinosESignModule.instance;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get SDK information
|
|
58
|
+
*/
|
|
59
|
+
async getSDKInfo() {
|
|
60
|
+
try {
|
|
61
|
+
const nativeInfo = await this.sdk.getSDKInfo();
|
|
62
|
+
return Object.assign(Object.assign({}, nativeInfo), { platform: this.platform, isInitialized: this.isInitialized });
|
|
63
|
+
}
|
|
64
|
+
catch (error) {
|
|
65
|
+
return {
|
|
66
|
+
name: EKYCModule_1.SDK_NAME,
|
|
67
|
+
version: EKYCModule_1.SDK_VERSION,
|
|
68
|
+
buildNumber: '1',
|
|
69
|
+
platform: this.platform,
|
|
70
|
+
isInitialized: this.isInitialized
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Initialize the eSign SDK
|
|
76
|
+
* Must be called before using any other methods
|
|
77
|
+
*/
|
|
78
|
+
async initialize() {
|
|
79
|
+
try {
|
|
80
|
+
if (this.isInitialized) {
|
|
81
|
+
console.log('✅ SDK already initialized');
|
|
82
|
+
return 'SDK already initialized';
|
|
83
|
+
}
|
|
84
|
+
// Check if SDK is already initialized on native side
|
|
85
|
+
if (this.sdk.isSDKInitialized()) {
|
|
86
|
+
this.isInitialized = true;
|
|
87
|
+
console.log('✅ SDK already initialized on native side');
|
|
88
|
+
return 'SDK already initialized on native side';
|
|
89
|
+
}
|
|
90
|
+
const result = await this.sdk.initSdkEkyc();
|
|
91
|
+
this.isInitialized = true;
|
|
92
|
+
console.log(`✅ Finos eSign SDK v${EKYCModule_1.SDK_VERSION} initialized successfully`);
|
|
93
|
+
return result;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
// Handle Koin Application already started error
|
|
97
|
+
if (error && error.toString().includes('Koin Application has already been started')) {
|
|
98
|
+
console.log('✅ SDK already initialized (Koin Application started)');
|
|
99
|
+
this.isInitialized = true;
|
|
100
|
+
return 'SDK already initialized (Koin Application started)';
|
|
101
|
+
}
|
|
102
|
+
console.error('❌ Failed to initialize Finos eSign SDK:', error);
|
|
103
|
+
throw new Error(`SDK initialization failed: ${error}`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Check if SDK is initialized
|
|
108
|
+
*/
|
|
109
|
+
isSDKReady() {
|
|
110
|
+
return this.isInitialized && this.sdk.isSDKInitialized();
|
|
111
|
+
}
|
|
112
|
+
// ==================== SMS OTP Methods ====================
|
|
113
|
+
/**
|
|
114
|
+
* Send SMS OTP
|
|
115
|
+
* @param config SMS OTP configuration
|
|
116
|
+
*/
|
|
117
|
+
async sendOtp(config) {
|
|
118
|
+
this.validateSDKReady();
|
|
119
|
+
try {
|
|
120
|
+
console.log('📱 Sending SMS OTP...');
|
|
121
|
+
const result = await this.sdk.sendOtp(config);
|
|
122
|
+
console.log('✅ SMS OTP sent successfully');
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
console.error('❌ SMS OTP send failed:', error);
|
|
127
|
+
throw error;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Verify SMS OTP
|
|
132
|
+
* @param config SMS OTP configuration (must include requestId)
|
|
133
|
+
* @param otpCode OTP code from SMS
|
|
134
|
+
*/
|
|
135
|
+
async verifyOtp(config, otpCode) {
|
|
136
|
+
this.validateSDKReady();
|
|
137
|
+
try {
|
|
138
|
+
console.log('🔐 Verifying SMS OTP...');
|
|
139
|
+
const result = await this.sdk.verifyOtp(config, otpCode);
|
|
140
|
+
console.log('✅ SMS OTP verified successfully');
|
|
141
|
+
return result;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
console.error('❌ SMS OTP verification failed:', error);
|
|
145
|
+
throw error;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Resend SMS OTP
|
|
150
|
+
* @param config SMS OTP configuration (must include requestId)
|
|
151
|
+
*/
|
|
152
|
+
async resendOtp(config) {
|
|
153
|
+
this.validateSDKReady();
|
|
154
|
+
try {
|
|
155
|
+
console.log('📱 Resending SMS OTP...');
|
|
156
|
+
const result = await this.sdk.resendOtp(config);
|
|
157
|
+
console.log('✅ SMS OTP resent successfully');
|
|
158
|
+
return result;
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
console.error('❌ SMS OTP resend failed:', error);
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
// SMS OTP Event Listeners
|
|
166
|
+
onSmsOtpSendSuccess(callback) {
|
|
167
|
+
const listener = this.sdk.onSmsOtpSendSuccess(callback);
|
|
168
|
+
if (!listener) {
|
|
169
|
+
console.warn('⚠️ onSmsOtpSendSuccess: Event emitter not ready. Make sure SDK is initialized.');
|
|
170
|
+
}
|
|
171
|
+
return listener;
|
|
172
|
+
}
|
|
173
|
+
onSmsOtpVerifySuccess(callback) {
|
|
174
|
+
const listener = this.sdk.onSmsOtpVerifySuccess(callback);
|
|
175
|
+
if (!listener) {
|
|
176
|
+
console.warn('⚠️ onSmsOtpVerifySuccess: Event emitter not ready.');
|
|
177
|
+
}
|
|
178
|
+
return listener;
|
|
179
|
+
}
|
|
180
|
+
onSmsOtpResendSuccess(callback) {
|
|
181
|
+
const listener = this.sdk.onSmsOtpResendSuccess(callback);
|
|
182
|
+
if (!listener) {
|
|
183
|
+
console.warn('⚠️ onSmsOtpResendSuccess: Event emitter not ready.');
|
|
184
|
+
}
|
|
185
|
+
return listener;
|
|
186
|
+
}
|
|
187
|
+
onSmsOtpError(callback) {
|
|
188
|
+
const listener = this.sdk.onSmsOtpError(callback);
|
|
189
|
+
if (!listener) {
|
|
190
|
+
console.warn('⚠️ onSmsOtpError: Event emitter not ready.');
|
|
191
|
+
}
|
|
192
|
+
return listener;
|
|
193
|
+
}
|
|
194
|
+
// ==================== eSign Methods ====================
|
|
195
|
+
/**
|
|
196
|
+
* Initialize eSign SDK
|
|
197
|
+
*/
|
|
198
|
+
async initializeESign() {
|
|
199
|
+
this.validateSDKReady();
|
|
200
|
+
try {
|
|
201
|
+
console.log('🔐 Initializing eSign SDK...');
|
|
202
|
+
const result = await this.sdk.initializeESign();
|
|
203
|
+
console.log('✅ eSign SDK initialized successfully');
|
|
204
|
+
return result;
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
console.error('❌ eSign initialization failed:', error);
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Open eSign session
|
|
213
|
+
* @param accessToken JWT access token (optional if using userEsignModel)
|
|
214
|
+
* @param username Optional username
|
|
215
|
+
* @param rememberMe Remember session
|
|
216
|
+
* @param userEsignModel User info for auto token creation (optional if using accessToken)
|
|
217
|
+
* @param privateKeyFilePath Path to private key file in assets (required if using userEsignModel)
|
|
218
|
+
*/
|
|
219
|
+
async openSessionId(accessToken, username, rememberMe, userEsignModel, privateKeyFilePath) {
|
|
220
|
+
this.validateSDKReady();
|
|
221
|
+
try {
|
|
222
|
+
console.log('🔓 Opening eSign session...');
|
|
223
|
+
const result = await this.sdk.openSessionId(accessToken, username, rememberMe, userEsignModel, privateKeyFilePath);
|
|
224
|
+
console.log('✅ eSign session opened successfully');
|
|
225
|
+
return result;
|
|
226
|
+
}
|
|
227
|
+
catch (error) {
|
|
228
|
+
console.error('❌ eSign session open failed:', error);
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Register device for eSign
|
|
234
|
+
* @param recoverCode 8-digit recovery code
|
|
235
|
+
* @param pinCode 6-digit PIN code
|
|
236
|
+
* @param fcmToken Optional FCM token
|
|
237
|
+
*/
|
|
238
|
+
async registerDevice(recoverCode, pinCode, fcmToken) {
|
|
239
|
+
this.validateSDKReady();
|
|
240
|
+
try {
|
|
241
|
+
console.log('📱 Registering eSign device...');
|
|
242
|
+
const result = await this.sdk.registerDevice(recoverCode, pinCode, fcmToken);
|
|
243
|
+
console.log('✅ eSign device registered successfully');
|
|
244
|
+
return result;
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
console.error('❌ eSign device registration failed:', error);
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* List eSign certificates
|
|
253
|
+
* @param pageNumber Page number (default: 1)
|
|
254
|
+
* @param pageSize Page size (default: 10)
|
|
255
|
+
*/
|
|
256
|
+
async listCerts(pageNumber = 1, pageSize = 10) {
|
|
257
|
+
this.validateSDKReady();
|
|
258
|
+
try {
|
|
259
|
+
console.log('📋 Listing eSign certificates...');
|
|
260
|
+
const result = await this.sdk.listCerts(pageNumber, pageSize);
|
|
261
|
+
console.log(`✅ Found ${result.certs.length} certificates`);
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
catch (error) {
|
|
265
|
+
console.error('❌ eSign list certificates failed:', error);
|
|
266
|
+
throw error;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Verify eSign certificate
|
|
271
|
+
* @param serial Certificate serial number
|
|
272
|
+
*/
|
|
273
|
+
async verifyCert(serial) {
|
|
274
|
+
this.validateSDKReady();
|
|
275
|
+
try {
|
|
276
|
+
console.log('✅ Verifying eSign certificate...');
|
|
277
|
+
const result = await this.sdk.verifyCert(serial);
|
|
278
|
+
console.log('✅ eSign certificate verified successfully');
|
|
279
|
+
return result;
|
|
280
|
+
}
|
|
281
|
+
catch (error) {
|
|
282
|
+
console.error('❌ eSign certificate verification failed:', error);
|
|
283
|
+
throw error;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* List eSign sign requests
|
|
288
|
+
* @param pageNumber Page number (default: 1)
|
|
289
|
+
* @param pageSize Page size (default: 10)
|
|
290
|
+
*/
|
|
291
|
+
async listSignRequest(pageNumber = 1, pageSize = 10) {
|
|
292
|
+
this.validateSDKReady();
|
|
293
|
+
try {
|
|
294
|
+
console.log('📋 Listing eSign sign requests...');
|
|
295
|
+
const result = await this.sdk.listSignRequest(pageNumber, pageSize);
|
|
296
|
+
console.log(`✅ Found ${result.requests.length} sign requests`);
|
|
297
|
+
return result;
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
console.error('❌ eSign list sign requests failed:', error);
|
|
301
|
+
throw error;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Confirm eSign signature
|
|
306
|
+
* @param signRequestId Sign request ID
|
|
307
|
+
* @param pinCode 6-digit PIN code
|
|
308
|
+
* @param authId Optional auth ID
|
|
309
|
+
* @param authData Optional auth data
|
|
310
|
+
* @param confirm Confirm the signature (default: true)
|
|
311
|
+
*/
|
|
312
|
+
async confirmSign(signRequestId, pinCode, authId, authData, confirm = true) {
|
|
313
|
+
this.validateSDKReady();
|
|
314
|
+
try {
|
|
315
|
+
console.log('✍️ Confirming eSign signature...');
|
|
316
|
+
const result = await this.sdk.confirmSign(signRequestId, pinCode, authId, authData, confirm);
|
|
317
|
+
console.log('✅ eSign signature confirmed successfully');
|
|
318
|
+
return result;
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
console.error('❌ eSign signature confirmation failed:', error);
|
|
322
|
+
throw error;
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Authenticate with eSign
|
|
327
|
+
* @param username eSign username
|
|
328
|
+
* @param password eSign password
|
|
329
|
+
*/
|
|
330
|
+
async authenticate(username, password) {
|
|
331
|
+
this.validateSDKReady();
|
|
332
|
+
try {
|
|
333
|
+
console.log('🔐 Authenticating with eSign...');
|
|
334
|
+
const result = await this.sdk.authenticate(username, password);
|
|
335
|
+
console.log('✅ eSign authentication successful');
|
|
336
|
+
return result;
|
|
337
|
+
}
|
|
338
|
+
catch (error) {
|
|
339
|
+
console.error('❌ eSign authentication failed:', error);
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Register remote signing certificate
|
|
345
|
+
* @param accessToken JWT access token
|
|
346
|
+
* @param requestJson JSON request body
|
|
347
|
+
*/
|
|
348
|
+
async registerRemoteSigning(accessToken, requestJson) {
|
|
349
|
+
this.validateSDKReady();
|
|
350
|
+
try {
|
|
351
|
+
console.log('📝 Registering remote signing certificate...');
|
|
352
|
+
const result = await this.sdk.registerRemoteSigning(accessToken, requestJson);
|
|
353
|
+
console.log('✅ Remote signing certificate registered successfully');
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
catch (error) {
|
|
357
|
+
console.error('❌ Remote signing certificate registration failed:', error);
|
|
358
|
+
throw error;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Sign PDF document
|
|
363
|
+
* @param accessToken JWT access token
|
|
364
|
+
* @param requestJson JSON request body
|
|
365
|
+
*/
|
|
366
|
+
async signPdf(accessToken, requestJson) {
|
|
367
|
+
this.validateSDKReady();
|
|
368
|
+
try {
|
|
369
|
+
console.log('📄 Signing PDF document...');
|
|
370
|
+
const result = await this.sdk.signPdf(accessToken, requestJson);
|
|
371
|
+
console.log('✅ PDF document signed successfully');
|
|
372
|
+
return result;
|
|
373
|
+
}
|
|
374
|
+
catch (error) {
|
|
375
|
+
console.error('❌ PDF document signing failed:', error);
|
|
376
|
+
throw error;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
/**
|
|
380
|
+
* Send confirmation document
|
|
381
|
+
* @param accessToken JWT access token
|
|
382
|
+
* @param requestJson JSON string containing request data
|
|
383
|
+
*/
|
|
384
|
+
async sendConfirmationDocument(accessToken, requestJson) {
|
|
385
|
+
this.validateSDKReady();
|
|
386
|
+
try {
|
|
387
|
+
console.log('📧 Sending confirmation document...');
|
|
388
|
+
const result = await this.sdk.sendConfirmationDocument(accessToken, requestJson);
|
|
389
|
+
console.log('✅ Confirmation document sent successfully');
|
|
390
|
+
return result;
|
|
391
|
+
}
|
|
392
|
+
catch (error) {
|
|
393
|
+
console.error('❌ Confirmation document sending failed:', error);
|
|
394
|
+
throw error;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* Remove all event listeners
|
|
399
|
+
*/
|
|
400
|
+
removeAllListeners() {
|
|
401
|
+
this.sdk.removeAllListeners();
|
|
402
|
+
console.log('🧹 All event listeners removed');
|
|
403
|
+
}
|
|
404
|
+
// eSign Event Listeners
|
|
405
|
+
onESignInitSuccess(callback) {
|
|
406
|
+
const listener = this.sdk.onESignInitSuccess(callback);
|
|
407
|
+
if (!listener) {
|
|
408
|
+
console.warn('⚠️ onESignInitSuccess: Event emitter not ready. Make sure SDK is initialized.');
|
|
409
|
+
}
|
|
410
|
+
return listener;
|
|
411
|
+
}
|
|
412
|
+
onESignOpenSessionSuccess(callback) {
|
|
413
|
+
const listener = this.sdk.onESignOpenSessionSuccess(callback);
|
|
414
|
+
if (!listener) {
|
|
415
|
+
console.warn('⚠️ onESignOpenSessionSuccess: Event emitter not ready.');
|
|
416
|
+
}
|
|
417
|
+
return listener;
|
|
418
|
+
}
|
|
419
|
+
onESignRegisterDeviceSuccess(callback) {
|
|
420
|
+
const listener = this.sdk.onESignRegisterDeviceSuccess(callback);
|
|
421
|
+
if (!listener) {
|
|
422
|
+
console.warn('⚠️ onESignRegisterDeviceSuccess: Event emitter not ready.');
|
|
423
|
+
}
|
|
424
|
+
return listener;
|
|
425
|
+
}
|
|
426
|
+
onESignListCertsSuccess(callback) {
|
|
427
|
+
const listener = this.sdk.onESignListCertsSuccess(callback);
|
|
428
|
+
if (!listener) {
|
|
429
|
+
console.warn('⚠️ onESignListCertsSuccess: Event emitter not ready.');
|
|
430
|
+
}
|
|
431
|
+
return listener;
|
|
432
|
+
}
|
|
433
|
+
onESignVerifyCertSuccess(callback) {
|
|
434
|
+
const listener = this.sdk.onESignVerifyCertSuccess(callback);
|
|
435
|
+
if (!listener) {
|
|
436
|
+
console.warn('⚠️ onESignVerifyCertSuccess: Event emitter not ready.');
|
|
437
|
+
}
|
|
438
|
+
return listener;
|
|
439
|
+
}
|
|
440
|
+
onESignListSignRequestSuccess(callback) {
|
|
441
|
+
const listener = this.sdk.onESignListSignRequestSuccess(callback);
|
|
442
|
+
if (!listener) {
|
|
443
|
+
console.warn('⚠️ onESignListSignRequestSuccess: Event emitter not ready.');
|
|
444
|
+
}
|
|
445
|
+
return listener;
|
|
446
|
+
}
|
|
447
|
+
onESignConfirmSignSuccess(callback) {
|
|
448
|
+
const listener = this.sdk.onESignConfirmSignSuccess(callback);
|
|
449
|
+
if (!listener) {
|
|
450
|
+
console.warn('⚠️ onESignConfirmSignSuccess: Event emitter not ready.');
|
|
451
|
+
}
|
|
452
|
+
return listener;
|
|
453
|
+
}
|
|
454
|
+
onESignAuthenticateSuccess(callback) {
|
|
455
|
+
const listener = this.sdk.onESignAuthenticateSuccess(callback);
|
|
456
|
+
if (!listener) {
|
|
457
|
+
console.warn('⚠️ onESignAuthenticateSuccess: Event emitter not ready.');
|
|
458
|
+
}
|
|
459
|
+
return listener;
|
|
460
|
+
}
|
|
461
|
+
onESignRegisterRemoteSigningSuccess(callback) {
|
|
462
|
+
const listener = this.sdk.onESignRegisterRemoteSigningSuccess(callback);
|
|
463
|
+
if (!listener) {
|
|
464
|
+
console.warn('⚠️ onESignRegisterRemoteSigningSuccess: Event emitter not ready.');
|
|
465
|
+
}
|
|
466
|
+
return listener;
|
|
467
|
+
}
|
|
468
|
+
onESignSignPdfSuccess(callback) {
|
|
469
|
+
const listener = this.sdk.onESignSignPdfSuccess(callback);
|
|
470
|
+
if (!listener) {
|
|
471
|
+
console.warn('⚠️ onESignSignPdfSuccess: Event emitter not ready.');
|
|
472
|
+
}
|
|
473
|
+
return listener;
|
|
474
|
+
}
|
|
475
|
+
onESignSendConfirmationDocumentSuccess(callback) {
|
|
476
|
+
const listener = this.sdk.onESignSendConfirmationDocumentSuccess(callback);
|
|
477
|
+
if (!listener) {
|
|
478
|
+
console.warn('⚠️ onESignSendConfirmationDocumentSuccess: Event emitter not ready.');
|
|
479
|
+
}
|
|
480
|
+
return listener;
|
|
481
|
+
}
|
|
482
|
+
onESignError(callback) {
|
|
483
|
+
const listener = this.sdk.onESignError(callback);
|
|
484
|
+
if (!listener) {
|
|
485
|
+
console.warn('⚠️ onESignError: Event emitter not ready.');
|
|
486
|
+
}
|
|
487
|
+
return listener;
|
|
488
|
+
}
|
|
489
|
+
// ==================== Liveness Methods ====================
|
|
490
|
+
/**
|
|
491
|
+
* Start liveness detection
|
|
492
|
+
* @param config Liveness configuration (includes switchFrontCamera for camera control)
|
|
493
|
+
*/
|
|
494
|
+
async startLiveness(config) {
|
|
495
|
+
this.validateSDKReady();
|
|
496
|
+
try {
|
|
497
|
+
console.log('👁️ Starting liveness detection...');
|
|
498
|
+
if (config.switchFrontCamera !== undefined) {
|
|
499
|
+
console.log('📷 Front camera setting:', config.switchFrontCamera ? 'ON' : 'OFF');
|
|
500
|
+
}
|
|
501
|
+
const result = await this.sdk.startLiveness(config);
|
|
502
|
+
console.log('✅ Liveness detection completed:', result.event);
|
|
503
|
+
return result;
|
|
504
|
+
}
|
|
505
|
+
catch (error) {
|
|
506
|
+
console.error('❌ Liveness detection failed:', error);
|
|
507
|
+
throw error;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
// Liveness Event Listeners
|
|
511
|
+
onLivenessSuccess(callback) {
|
|
512
|
+
return this.sdk.onLivenessSuccess(callback);
|
|
513
|
+
}
|
|
514
|
+
onLivenessError(callback) {
|
|
515
|
+
return this.sdk.onLivenessError(callback);
|
|
516
|
+
}
|
|
517
|
+
// ==================== Face Service Methods ====================
|
|
518
|
+
/**
|
|
519
|
+
* Start face comparison
|
|
520
|
+
* @param config Face service configuration
|
|
521
|
+
*/
|
|
522
|
+
async startFaceCompare(config) {
|
|
523
|
+
this.validateSDKReady();
|
|
524
|
+
try {
|
|
525
|
+
console.log('👤 Starting face comparison...');
|
|
526
|
+
const result = await this.sdk.startFaceCompare(config);
|
|
527
|
+
console.log('✅ Face comparison completed:', result.event);
|
|
528
|
+
return result;
|
|
529
|
+
}
|
|
530
|
+
catch (error) {
|
|
531
|
+
console.error('❌ Face comparison failed:', error);
|
|
532
|
+
throw error;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
// Face Compare Event Listeners
|
|
536
|
+
onFaceCompareSuccess(callback) {
|
|
537
|
+
return this.sdk.onFaceCompareSuccess(callback);
|
|
538
|
+
}
|
|
539
|
+
onFaceCompareError(callback) {
|
|
540
|
+
return this.sdk.onFaceCompareError(callback);
|
|
541
|
+
}
|
|
542
|
+
// ==================== eKYC UI Methods ====================
|
|
543
|
+
/**
|
|
544
|
+
* Start eKYC UI with flow (excluding NFC, C06, OCR)
|
|
545
|
+
* Only supports LIVENESS and FACE in flowSDK array
|
|
546
|
+
* @param appKey Main app key
|
|
547
|
+
* @param flowSDK Array of SDK types (only 'LIVENESS' and 'FACE' are allowed)
|
|
548
|
+
* @param language Language code (vi/en)
|
|
549
|
+
* @param transactionId Transaction ID
|
|
550
|
+
* @param appKeyConfig App key configuration
|
|
551
|
+
* @param optionConfig Optional configuration settings (includes switchFrontCamera for camera control)
|
|
552
|
+
* @param styleConfig Optional style configuration
|
|
553
|
+
*/
|
|
554
|
+
async startEkycUI(appKey, flowSDK, language, transactionId, appKeyConfig, optionConfig, styleConfig) {
|
|
555
|
+
this.validateSDKReady();
|
|
556
|
+
// Validate flowSDK - only allow LIVENESS and FACE
|
|
557
|
+
const allowedTypes = ['LIVENESS', 'FACE'];
|
|
558
|
+
const invalidTypes = flowSDK.filter(type => !allowedTypes.includes(type));
|
|
559
|
+
if (invalidTypes.length > 0) {
|
|
560
|
+
throw new Error(`Invalid SDK types in flowSDK: ${invalidTypes.join(', ')}. Only 'LIVENESS' and 'FACE' are allowed in FinosESignModule.`);
|
|
561
|
+
}
|
|
562
|
+
if (flowSDK.length === 0) {
|
|
563
|
+
throw new Error('flowSDK must contain at least one SDK type (LIVENESS or FACE)');
|
|
564
|
+
}
|
|
565
|
+
try {
|
|
566
|
+
console.log('🚀 Starting eKYC UI with flow:', flowSDK);
|
|
567
|
+
console.log('🔧 OptionConfig:', optionConfig);
|
|
568
|
+
if ((optionConfig === null || optionConfig === void 0 ? void 0 : optionConfig.switchFrontCamera) !== undefined) {
|
|
569
|
+
console.log('📷 Front camera setting:', optionConfig.switchFrontCamera ? 'ON' : 'OFF');
|
|
570
|
+
}
|
|
571
|
+
console.log('🔑 AppKeyConfig:', appKeyConfig);
|
|
572
|
+
console.log('🎨 StyleConfig:', styleConfig);
|
|
573
|
+
// Create full appKeyConfig with empty values for excluded modules
|
|
574
|
+
const fullAppKeyConfig = {
|
|
575
|
+
appKey: appKeyConfig.appKey,
|
|
576
|
+
appKeyNfc: '',
|
|
577
|
+
appKeyOcr: '',
|
|
578
|
+
appKeyLiveness: appKeyConfig.appKeyLiveness,
|
|
579
|
+
appKeyC06: '',
|
|
580
|
+
appKeyFaceService: appKeyConfig.appKeyFaceService,
|
|
581
|
+
};
|
|
582
|
+
const result = await this.sdk.startEkycUI(appKey, flowSDK, language, transactionId, fullAppKeyConfig, optionConfig, styleConfig);
|
|
583
|
+
console.log('✅ eKYC UI started successfully');
|
|
584
|
+
return result;
|
|
585
|
+
}
|
|
586
|
+
catch (error) {
|
|
587
|
+
console.error('❌ eKYC UI failed:', error);
|
|
588
|
+
throw error;
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
// Private validation methods
|
|
592
|
+
validateSDKReady() {
|
|
593
|
+
if (!this.isSDKReady()) {
|
|
594
|
+
throw new Error('SDK is not initialized. Please call initialize() first.');
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
exports.FinosESignModule = FinosESignModule;
|
|
599
|
+
// Export singleton instance - ensure it's always initialized
|
|
600
|
+
let _finosESignInstance = null;
|
|
601
|
+
const getFinosESignInstance = () => {
|
|
602
|
+
if (!_finosESignInstance) {
|
|
603
|
+
try {
|
|
604
|
+
_finosESignInstance = FinosESignModule.getInstance();
|
|
605
|
+
}
|
|
606
|
+
catch (error) {
|
|
607
|
+
console.error('Failed to initialize FinosESignModule:', error);
|
|
608
|
+
throw new Error('FinosESignModule initialization failed. Please check native module setup.');
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
return _finosESignInstance;
|
|
612
|
+
};
|
|
613
|
+
// Initialize immediately
|
|
614
|
+
try {
|
|
615
|
+
_finosESignInstance = FinosESignModule.getInstance();
|
|
616
|
+
}
|
|
617
|
+
catch (error) {
|
|
618
|
+
// Silent initialization - will be created on first access
|
|
619
|
+
}
|
|
620
|
+
// Helper to check if a property is a method on FinosESignModule
|
|
621
|
+
const isMethod = (prop) => {
|
|
622
|
+
if (typeof prop !== 'string')
|
|
623
|
+
return false;
|
|
624
|
+
// Check if it's a known method from the class
|
|
625
|
+
const prototype = FinosESignModule.prototype;
|
|
626
|
+
return typeof prototype[prop] === 'function' ||
|
|
627
|
+
prop.startsWith('on') ||
|
|
628
|
+
prop === 'initialize' ||
|
|
629
|
+
prop === 'initializeESign' ||
|
|
630
|
+
prop === 'sendOtp' ||
|
|
631
|
+
prop === 'verifyOtp' ||
|
|
632
|
+
prop === 'resendOtp' ||
|
|
633
|
+
prop === 'openSessionId' ||
|
|
634
|
+
prop === 'registerDevice' ||
|
|
635
|
+
prop === 'listCerts' ||
|
|
636
|
+
prop === 'verifyCert' ||
|
|
637
|
+
prop === 'listSignRequest' ||
|
|
638
|
+
prop === 'confirmSign' ||
|
|
639
|
+
prop === 'authenticate' ||
|
|
640
|
+
prop === 'registerRemoteSigning' ||
|
|
641
|
+
prop === 'signPdf' ||
|
|
642
|
+
prop === 'sendConfirmationDocument' ||
|
|
643
|
+
prop === 'startLiveness' ||
|
|
644
|
+
prop === 'startFaceCompare' ||
|
|
645
|
+
prop === 'startEkycUI';
|
|
646
|
+
};
|
|
647
|
+
// Create a safe wrapper using Proxy - ensure it's always an object
|
|
648
|
+
const createFinosESignProxy = () => {
|
|
649
|
+
try {
|
|
650
|
+
return new Proxy({}, {
|
|
651
|
+
get(_target, prop) {
|
|
652
|
+
try {
|
|
653
|
+
const instance = getFinosESignInstance();
|
|
654
|
+
const value = instance[prop];
|
|
655
|
+
if (typeof value === 'function') {
|
|
656
|
+
return value.bind(instance);
|
|
657
|
+
}
|
|
658
|
+
return value;
|
|
659
|
+
}
|
|
660
|
+
catch (error) {
|
|
661
|
+
console.warn(`⚠️ FinosESign.${String(prop)} is not available:`, error);
|
|
662
|
+
// Always return a function for methods to prevent "undefined" errors
|
|
663
|
+
if (isMethod(prop)) {
|
|
664
|
+
// For event listeners (on* methods), return a function that returns null
|
|
665
|
+
if (typeof prop === 'string' && prop.startsWith('on')) {
|
|
666
|
+
return (callback) => {
|
|
667
|
+
console.warn(`⚠️ FinosESign.${prop} called but module is not initialized`);
|
|
668
|
+
return null;
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
// For other methods, return a no-op async function
|
|
672
|
+
return async (...args) => {
|
|
673
|
+
console.warn(`⚠️ FinosESign.${String(prop)} called but module is not initialized`);
|
|
674
|
+
throw new Error(`FinosESign.${String(prop)} is not available. Module may not be initialized.`);
|
|
675
|
+
};
|
|
676
|
+
}
|
|
677
|
+
return undefined;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
catch (error) {
|
|
683
|
+
console.error('❌ Failed to create FinosESign proxy:', error);
|
|
684
|
+
// Return a comprehensive stub object
|
|
685
|
+
return createFinosESignStub();
|
|
686
|
+
}
|
|
687
|
+
};
|
|
688
|
+
// Create a comprehensive stub object with all methods to prevent undefined errors
|
|
689
|
+
const createFinosESignStub = () => {
|
|
690
|
+
const stub = {};
|
|
691
|
+
// Add all event listener methods (on* methods)
|
|
692
|
+
const eventListenerMethods = [
|
|
693
|
+
'onSmsOtpSendSuccess', 'onSmsOtpVerifySuccess', 'onSmsOtpResendSuccess', 'onSmsOtpError',
|
|
694
|
+
'onESignInitSuccess', 'onESignOpenSessionSuccess', 'onESignRegisterDeviceSuccess',
|
|
695
|
+
'onESignListCertsSuccess', 'onESignVerifyCertSuccess', 'onESignListSignRequestSuccess',
|
|
696
|
+
'onESignConfirmSignSuccess', 'onESignAuthenticateSuccess', 'onESignRegisterRemoteSigningSuccess',
|
|
697
|
+
'onESignSignPdfSuccess', 'onESignSendConfirmationDocumentSuccess', 'onESignError',
|
|
698
|
+
'onLivenessSuccess', 'onLivenessError', 'onFaceCompareSuccess', 'onFaceCompareError'
|
|
699
|
+
];
|
|
700
|
+
eventListenerMethods.forEach(method => {
|
|
701
|
+
stub[method] = (callback) => {
|
|
702
|
+
console.warn(`⚠️ FinosESign.${method} called but module is not initialized`);
|
|
703
|
+
return null;
|
|
704
|
+
};
|
|
705
|
+
});
|
|
706
|
+
// Add all other methods
|
|
707
|
+
const otherMethods = [
|
|
708
|
+
'initialize', 'initializeESign', 'sendOtp', 'verifyOtp', 'resendOtp',
|
|
709
|
+
'openSessionId', 'registerDevice', 'listCerts', 'verifyCert', 'listSignRequest',
|
|
710
|
+
'confirmSign', 'authenticate', 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
|
|
711
|
+
'startLiveness', 'startFaceCompare', 'startEkycUI', 'isSDKReady', 'getSDKInfo'
|
|
712
|
+
];
|
|
713
|
+
otherMethods.forEach(method => {
|
|
714
|
+
stub[method] = async (...args) => {
|
|
715
|
+
console.warn(`⚠️ FinosESign.${method} called but module is not initialized`);
|
|
716
|
+
throw new Error(`FinosESign.${method} is not available. Module may not be initialized.`);
|
|
717
|
+
};
|
|
718
|
+
});
|
|
719
|
+
return stub;
|
|
720
|
+
};
|
|
721
|
+
// Create a wrapper that always returns a valid object
|
|
722
|
+
// This ensures FinosESign is NEVER undefined and always has all methods
|
|
723
|
+
const createFinosESignWrapper = () => {
|
|
724
|
+
// Always start with stub to ensure all methods exist
|
|
725
|
+
const stub = createFinosESignStub();
|
|
726
|
+
const wrapper = Object.assign({}, stub);
|
|
727
|
+
// Try to get real instance and override methods
|
|
728
|
+
try {
|
|
729
|
+
const realInstance = getFinosESignInstance();
|
|
730
|
+
// Override with real instance methods
|
|
731
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(realInstance)).forEach(key => {
|
|
732
|
+
if (key !== 'constructor' && typeof realInstance[key] === 'function') {
|
|
733
|
+
wrapper[key] = (realInstance[key]).bind(realInstance);
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
// Also copy any own properties from real instance
|
|
737
|
+
Object.keys(realInstance).forEach(key => {
|
|
738
|
+
if (realInstance[key] !== undefined) {
|
|
739
|
+
wrapper[key] = realInstance[key];
|
|
740
|
+
}
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
catch (error) {
|
|
744
|
+
// If we can't get instance, wrapper already has all stub methods
|
|
745
|
+
// No need to do anything
|
|
746
|
+
}
|
|
747
|
+
return wrapper;
|
|
748
|
+
};
|
|
749
|
+
// Export - this ensures FinosESign is never undefined
|
|
750
|
+
exports.FinosESign = createFinosESignWrapper();
|
|
751
|
+
// Default export
|
|
752
|
+
exports.default = exports.FinosESign;
|