@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.
Files changed (85) hide show
  1. package/LICENSE +13 -10
  2. package/README.md +41 -42
  3. package/android/build.gradle +42 -11
  4. package/android/gradle.properties +7 -1
  5. package/android/settings.gradle +53 -0
  6. package/android/src/main/java/finos/sdk/ekyc/EKYCModule.kt +791 -81
  7. package/dist/EKYCModule.d.ts +73 -0
  8. package/dist/EKYCModule.js +663 -71
  9. package/dist/index.d.ts +6 -1
  10. package/dist/index.js +5 -1
  11. package/dist/package.json +31 -21
  12. package/dist/src/modules/FinosEKYCModule.d.ts +149 -0
  13. package/dist/src/modules/FinosEKYCModule.js +485 -2
  14. package/dist/src/modules/FinosESignModule.d.ts +270 -0
  15. package/dist/src/modules/FinosESignModule.js +752 -0
  16. package/dist/src/types/ekycESignType.d.ts +67 -0
  17. package/dist/src/types/ekycESignType.js +2 -0
  18. package/dist/src/types/ekycSmsOtpType.d.ts +52 -0
  19. package/dist/src/types/ekycSmsOtpType.js +2 -0
  20. package/package.json +31 -21
  21. package/src/modules/FinosEKYCModule.ts +572 -2
  22. package/src/modules/FinosESignModule.ts +919 -0
  23. package/src/modules/README.md +3 -3
  24. package/src/types/ekycESignType.ts +76 -0
  25. package/src/types/ekycSmsOtpType.ts +59 -0
  26. package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2-sources.jar +0 -0
  27. package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.aar +0 -0
  28. package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.module +0 -110
  29. package/android/SDKeKYC/finos/sdk/ekyc/c06/1.2.2/c06-1.2.2.pom +0 -37
  30. package/android/SDKeKYC/finos/sdk/ekyc/c06/maven-metadata-local.xml +0 -13
  31. package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2-sources.jar +0 -0
  32. package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.aar +0 -0
  33. package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.module +0 -201
  34. package/android/SDKeKYC/finos/sdk/ekyc/ekyc/1.2.2/ekyc-1.2.2.pom +0 -73
  35. package/android/SDKeKYC/finos/sdk/ekyc/ekyc/maven-metadata-local.xml +0 -13
  36. package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2-sources.jar +0 -0
  37. package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.aar +0 -0
  38. package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.module +0 -131
  39. package/android/SDKeKYC/finos/sdk/ekyc/ekycui/1.2.2/ekycui-1.2.2.pom +0 -43
  40. package/android/SDKeKYC/finos/sdk/ekyc/ekycui/maven-metadata-local.xml +0 -13
  41. package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2-sources.jar +0 -0
  42. package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.aar +0 -0
  43. package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.module +0 -110
  44. package/android/SDKeKYC/finos/sdk/ekyc/faceservice/1.2.2/faceservice-1.2.2.pom +0 -37
  45. package/android/SDKeKYC/finos/sdk/ekyc/faceservice/maven-metadata-local.xml +0 -13
  46. package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2-sources.jar +0 -0
  47. package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.aar +0 -0
  48. package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.module +0 -138
  49. package/android/SDKeKYC/finos/sdk/ekyc/liveness/1.2.2/liveness-1.2.2.pom +0 -55
  50. package/android/SDKeKYC/finos/sdk/ekyc/liveness/maven-metadata-local.xml +0 -13
  51. package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2-sources.jar +0 -0
  52. package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.aar +0 -0
  53. package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.module +0 -131
  54. package/android/SDKeKYC/finos/sdk/ekyc/nfc/1.2.2/nfc-1.2.2.pom +0 -55
  55. package/android/SDKeKYC/finos/sdk/ekyc/nfc/maven-metadata-local.xml +0 -13
  56. package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2-sources.jar +0 -0
  57. package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.aar +0 -0
  58. package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.module +0 -124
  59. package/android/SDKeKYC/finos/sdk/ekyc/ocr/1.2.2/ocr-1.2.2.pom +0 -43
  60. package/android/SDKeKYC/finos/sdk/ekyc/ocr/maven-metadata-local.xml +0 -13
  61. package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2-sources.jar +0 -0
  62. package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.aar +0 -0
  63. package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.module +0 -138
  64. package/android/SDKeKYC/finos/sdk/ekyc/qrcode/1.2.2/qrcode-1.2.2.pom +0 -55
  65. package/android/SDKeKYC/finos/sdk/ekyc/qrcode/maven-metadata-local.xml +0 -13
  66. package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2-sources.jar +0 -0
  67. package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.aar +0 -0
  68. package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.module +0 -341
  69. package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/1.2.2/sdkcore-1.2.2.pom +0 -139
  70. package/android/SDKeKYC/finos/sdk/ekyc/sdkcore/maven-metadata-local.xml +0 -13
  71. package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2-sources.jar +0 -0
  72. package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.aar +0 -0
  73. package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.module +0 -201
  74. package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/1.2.2/sdkcorecamera-1.2.2.pom +0 -85
  75. package/android/SDKeKYC/finos/sdk/ekyc/sdkcorecamera/maven-metadata-local.xml +0 -13
  76. package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2-sources.jar +0 -0
  77. package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.aar +0 -0
  78. package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.module +0 -208
  79. package/android/SDKeKYC/finos/sdk/ekyc/sdkui/1.2.2/sdkui-1.2.2.pom +0 -103
  80. package/android/SDKeKYC/finos/sdk/ekyc/sdkui/maven-metadata-local.xml +0 -13
  81. package/android/src/main/AndroidManifest.xml +0 -22
  82. package/android/src/main/build.gradle +0 -31
  83. package/dist/App.d.ts +0 -3
  84. package/dist/App.js +0 -497
  85. package/dist/finos_sdk-sdk-ekyc-1.2.2.tgz +0 -0
@@ -6,6 +6,8 @@ import { C06Config } from '../types/ekycC06Type';
6
6
  import { OcrConfig } from '../types/ekycOCRType';
7
7
  import { LivenessConfig } from '../types/ekycLivenessType';
8
8
  import { FaceServiceConfig } from '../types/ekycFaceType';
9
+ import { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';
10
+ import { UserEsignModel, ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
9
11
 
10
12
  /**
11
13
  * Finos eKYC SDK Module
@@ -108,6 +110,24 @@ export class FinosEKYCModule {
108
110
  return this.isInitialized && this.sdk.isSDKInitialized();
109
111
  }
110
112
 
113
+ /**
114
+ * Set transaction ID
115
+ * @param transactionId Transaction ID string
116
+ */
117
+ public async setTransactionId(transactionId: string): Promise<boolean> {
118
+ this.validateSDKReady();
119
+
120
+ try {
121
+ console.log('🆔 Setting transaction ID:', transactionId);
122
+ const result = await this.sdk.setTransactionId(transactionId);
123
+ console.log('✅ Transaction ID set successfully');
124
+ return result;
125
+ } catch (error) {
126
+ console.error('❌ Failed to set transaction ID:', error);
127
+ throw error;
128
+ }
129
+ }
130
+
111
131
  /**
112
132
  * Start NFC scanning for Vietnamese CCCD
113
133
  * @param config NFC configuration
@@ -330,6 +350,400 @@ export class FinosEKYCModule {
330
350
  console.log('🧹 All event listeners removed');
331
351
  }
332
352
 
353
+ // ==================== SMS OTP Methods ====================
354
+
355
+ /**
356
+ * Send SMS OTP
357
+ * @param config SMS OTP configuration
358
+ */
359
+ public async sendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
360
+ this.validateSDKReady();
361
+
362
+ try {
363
+ console.log('📱 Sending SMS OTP...');
364
+ const result = await this.sdk.sendOtp(config);
365
+ console.log('✅ SMS OTP sent successfully');
366
+ return result;
367
+ } catch (error) {
368
+ console.error('❌ SMS OTP send failed:', error);
369
+ throw error;
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Verify SMS OTP
375
+ * @param config SMS OTP configuration (must include requestId)
376
+ * @param otpCode OTP code from SMS
377
+ */
378
+ public async verifyOtp(config: SmsOtpConfig, otpCode: string): Promise<SmsOtpResult> {
379
+ this.validateSDKReady();
380
+
381
+ try {
382
+ console.log('🔐 Verifying SMS OTP...');
383
+ const result = await this.sdk.verifyOtp(config, otpCode);
384
+ console.log('✅ SMS OTP verified successfully');
385
+ return result;
386
+ } catch (error) {
387
+ console.error('❌ SMS OTP verification failed:', error);
388
+ throw error;
389
+ }
390
+ }
391
+
392
+ /**
393
+ * Resend SMS OTP
394
+ * @param config SMS OTP configuration (must include requestId)
395
+ */
396
+ public async resendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
397
+ this.validateSDKReady();
398
+
399
+ try {
400
+ console.log('📱 Resending SMS OTP...');
401
+ const result = await this.sdk.resendOtp(config);
402
+ console.log('✅ SMS OTP resent successfully');
403
+ return result;
404
+ } catch (error) {
405
+ console.error('❌ SMS OTP resend failed:', error);
406
+ throw error;
407
+ }
408
+ }
409
+
410
+ // SMS OTP Event Listeners
411
+ public onSmsOtpSendSuccess(callback: (data: SmsOtpResult) => void) {
412
+ const listener = this.sdk.onSmsOtpSendSuccess(callback);
413
+ if (!listener) {
414
+ console.warn('⚠️ onSmsOtpSendSuccess: Event emitter not ready. Make sure SDK is initialized.');
415
+ }
416
+ return listener;
417
+ }
418
+
419
+ public onSmsOtpVerifySuccess(callback: (data: SmsOtpResult) => void) {
420
+ const listener = this.sdk.onSmsOtpVerifySuccess(callback);
421
+ if (!listener) {
422
+ console.warn('⚠️ onSmsOtpVerifySuccess: Event emitter not ready.');
423
+ }
424
+ return listener;
425
+ }
426
+
427
+ public onSmsOtpResendSuccess(callback: (data: SmsOtpResult) => void) {
428
+ const listener = this.sdk.onSmsOtpResendSuccess(callback);
429
+ if (!listener) {
430
+ console.warn('⚠️ onSmsOtpResendSuccess: Event emitter not ready.');
431
+ }
432
+ return listener;
433
+ }
434
+
435
+ public onSmsOtpError(callback: (error: SmsOtpError) => void) {
436
+ const listener = this.sdk.onSmsOtpError(callback);
437
+ if (!listener) {
438
+ console.warn('⚠️ onSmsOtpError: Event emitter not ready.');
439
+ }
440
+ return listener;
441
+ }
442
+
443
+ // ==================== eSign Methods ====================
444
+
445
+ /**
446
+ * Initialize eSign SDK
447
+ */
448
+ public async initializeESign(): Promise<ESignInitResult> {
449
+ this.validateSDKReady();
450
+
451
+ try {
452
+ console.log('🔐 Initializing eSign SDK...');
453
+ const result = await this.sdk.initializeESign();
454
+ console.log('✅ eSign SDK initialized successfully');
455
+ return result;
456
+ } catch (error) {
457
+ console.error('❌ eSign initialization failed:', error);
458
+ throw error;
459
+ }
460
+ }
461
+
462
+ /**
463
+ * Open eSign session
464
+ * @param accessToken JWT access token (optional if using userEsignModel)
465
+ * @param username Optional username
466
+ * @param rememberMe Remember session
467
+ * @param userEsignModel User info for auto token creation (optional if using accessToken)
468
+ * @param privateKeyFilePath Path to private key file in assets (required if using userEsignModel)
469
+ */
470
+ public async openSessionId(
471
+ accessToken?: string,
472
+ username?: string,
473
+ rememberMe?: boolean,
474
+ userEsignModel?: UserEsignModel,
475
+ privateKeyFilePath?: string
476
+ ): Promise<ESignOpenSessionResult> {
477
+ this.validateSDKReady();
478
+
479
+ try {
480
+ console.log('🔓 Opening eSign session...');
481
+ const result = await this.sdk.openSessionId(
482
+ accessToken,
483
+ username,
484
+ rememberMe,
485
+ userEsignModel,
486
+ privateKeyFilePath
487
+ );
488
+ console.log('✅ eSign session opened successfully');
489
+ return result;
490
+ } catch (error) {
491
+ console.error('❌ eSign session open failed:', error);
492
+ throw error;
493
+ }
494
+ }
495
+
496
+ /**
497
+ * Register device for eSign
498
+ * @param recoverCode 8-digit recovery code
499
+ * @param pinCode 6-digit PIN code
500
+ * @param fcmToken Optional FCM token
501
+ */
502
+ public async registerDevice(
503
+ recoverCode: string,
504
+ pinCode: string,
505
+ fcmToken?: string
506
+ ): Promise<{ code: string; message: string }> {
507
+ this.validateSDKReady();
508
+
509
+ try {
510
+ console.log('📱 Registering eSign device...');
511
+ const result = await this.sdk.registerDevice(recoverCode, pinCode, fcmToken);
512
+ console.log('✅ eSign device registered successfully');
513
+ return result;
514
+ } catch (error) {
515
+ console.error('❌ eSign device registration failed:', error);
516
+ throw error;
517
+ }
518
+ }
519
+
520
+ /**
521
+ * List eSign certificates
522
+ * @param pageNumber Page number (default: 1)
523
+ * @param pageSize Page size (default: 10)
524
+ */
525
+ public async listCerts(
526
+ pageNumber: number = 1,
527
+ pageSize: number = 10
528
+ ): Promise<{ certs: ESignCertificate[] }> {
529
+ this.validateSDKReady();
530
+
531
+ try {
532
+ console.log('📋 Listing eSign certificates...');
533
+ const result = await this.sdk.listCerts(pageNumber, pageSize);
534
+ console.log(`✅ Found ${result.certs.length} certificates`);
535
+ return result;
536
+ } catch (error) {
537
+ console.error('❌ eSign list certificates failed:', error);
538
+ throw error;
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Verify eSign certificate
544
+ * @param serial Certificate serial number
545
+ */
546
+ public async verifyCert(serial: string): Promise<{ code: string; message: string }> {
547
+ this.validateSDKReady();
548
+
549
+ try {
550
+ console.log('✅ Verifying eSign certificate...');
551
+ const result = await this.sdk.verifyCert(serial);
552
+ console.log('✅ eSign certificate verified successfully');
553
+ return result;
554
+ } catch (error) {
555
+ console.error('❌ eSign certificate verification failed:', error);
556
+ throw error;
557
+ }
558
+ }
559
+
560
+ /**
561
+ * List eSign sign requests
562
+ * @param pageNumber Page number (default: 1)
563
+ * @param pageSize Page size (default: 10)
564
+ */
565
+ public async listSignRequest(
566
+ pageNumber: number = 1,
567
+ pageSize: number = 10
568
+ ): Promise<{ requests: ESignSignRequest[] }> {
569
+ this.validateSDKReady();
570
+
571
+ try {
572
+ console.log('📋 Listing eSign sign requests...');
573
+ const result = await this.sdk.listSignRequest(pageNumber, pageSize);
574
+ console.log(`✅ Found ${result.requests.length} sign requests`);
575
+ return result;
576
+ } catch (error) {
577
+ console.error('❌ eSign list sign requests failed:', error);
578
+ throw error;
579
+ }
580
+ }
581
+
582
+ /**
583
+ * Confirm eSign signature
584
+ * @param signRequestId Sign request ID
585
+ * @param pinCode 6-digit PIN code
586
+ * @param authId Optional auth ID
587
+ * @param authData Optional auth data
588
+ * @param confirm Confirm the signature (default: true)
589
+ */
590
+ public async confirmSign(
591
+ signRequestId: string,
592
+ pinCode: string,
593
+ authId?: string,
594
+ authData?: string,
595
+ confirm: boolean = true
596
+ ): Promise<{ code: string; message: string }> {
597
+ this.validateSDKReady();
598
+
599
+ try {
600
+ console.log('✍️ Confirming eSign signature...');
601
+ const result = await this.sdk.confirmSign(signRequestId, pinCode, authId, authData, confirm);
602
+ console.log('✅ eSign signature confirmed successfully');
603
+ return result;
604
+ } catch (error) {
605
+ console.error('❌ eSign signature confirmation failed:', error);
606
+ throw error;
607
+ }
608
+ }
609
+
610
+ /**
611
+ * Authenticate with eSign
612
+ * @param username eSign username
613
+ * @param password eSign password
614
+ */
615
+ public async authenticate(
616
+ username: string,
617
+ password: string
618
+ ): Promise<ESignAuthenticateResult> {
619
+ this.validateSDKReady();
620
+
621
+ try {
622
+ console.log('🔐 Authenticating with eSign...');
623
+ const result = await this.sdk.authenticate(username, password);
624
+ console.log('✅ eSign authentication successful');
625
+ return result;
626
+ } catch (error) {
627
+ console.error('❌ eSign authentication failed:', error);
628
+ throw error;
629
+ }
630
+ }
631
+
632
+ /**
633
+ * Register remote signing certificate
634
+ * @param accessToken JWT access token
635
+ * @param requestJson JSON request body
636
+ */
637
+ public async registerRemoteSigning(
638
+ accessToken: string,
639
+ requestJson: string
640
+ ): Promise<{ response: string }> {
641
+ this.validateSDKReady();
642
+
643
+ try {
644
+ console.log('📝 Registering remote signing certificate...');
645
+ const result = await this.sdk.registerRemoteSigning(accessToken, requestJson);
646
+ console.log('✅ Remote signing certificate registered successfully');
647
+ return result;
648
+ } catch (error) {
649
+ console.error('❌ Remote signing certificate registration failed:', error);
650
+ throw error;
651
+ }
652
+ }
653
+
654
+ /**
655
+ * Sign PDF document
656
+ * @param accessToken JWT access token
657
+ * @param requestJson JSON request body
658
+ */
659
+ public async signPdf(
660
+ accessToken: string,
661
+ requestJson: string
662
+ ): Promise<{ response: string }> {
663
+ this.validateSDKReady();
664
+
665
+ try {
666
+ console.log('📄 Signing PDF document...');
667
+ const result = await this.sdk.signPdf(accessToken, requestJson);
668
+ console.log('✅ PDF document signed successfully');
669
+ return result;
670
+ } catch (error) {
671
+ console.error('❌ PDF document signing failed:', error);
672
+ throw error;
673
+ }
674
+ }
675
+
676
+ /**
677
+ * Send confirmation document
678
+ * @param accessToken JWT access token
679
+ * @param requestJson JSON string containing request data
680
+ */
681
+ public async sendConfirmationDocument(
682
+ accessToken: string,
683
+ requestJson: string
684
+ ): Promise<{ response: string }> {
685
+ this.validateSDKReady();
686
+
687
+ try {
688
+ console.log('📧 Sending confirmation document...');
689
+ const result = await this.sdk.sendConfirmationDocument(accessToken, requestJson);
690
+ console.log('✅ Confirmation document sent successfully');
691
+ return result;
692
+ } catch (error) {
693
+ console.error('❌ Confirmation document sending failed:', error);
694
+ throw error;
695
+ }
696
+ }
697
+
698
+ // eSign Event Listeners
699
+ public onESignInitSuccess(callback: (data: ESignInitResult) => void) {
700
+ return this.sdk.onESignInitSuccess(callback);
701
+ }
702
+
703
+ public onESignOpenSessionSuccess(callback: (data: ESignOpenSessionResult) => void) {
704
+ return this.sdk.onESignOpenSessionSuccess(callback);
705
+ }
706
+
707
+ public onESignRegisterDeviceSuccess(callback: (data: { code: string; message: string }) => void) {
708
+ return this.sdk.onESignRegisterDeviceSuccess(callback);
709
+ }
710
+
711
+ public onESignListCertsSuccess(callback: (data: { certs: ESignCertificate[] }) => void) {
712
+ return this.sdk.onESignListCertsSuccess(callback);
713
+ }
714
+
715
+ public onESignVerifyCertSuccess(callback: (data: { code: string; message: string }) => void) {
716
+ return this.sdk.onESignVerifyCertSuccess(callback);
717
+ }
718
+
719
+ public onESignListSignRequestSuccess(callback: (data: { requests: ESignSignRequest[] }) => void) {
720
+ return this.sdk.onESignListSignRequestSuccess(callback);
721
+ }
722
+
723
+ public onESignConfirmSignSuccess(callback: (data: { code: string; message: string }) => void) {
724
+ return this.sdk.onESignConfirmSignSuccess(callback);
725
+ }
726
+
727
+ public onESignAuthenticateSuccess(callback: (data: ESignAuthenticateResult) => void) {
728
+ return this.sdk.onESignAuthenticateSuccess(callback);
729
+ }
730
+
731
+ public onESignRegisterRemoteSigningSuccess(callback: (data: { response: string }) => void) {
732
+ return this.sdk.onESignRegisterRemoteSigningSuccess(callback);
733
+ }
734
+
735
+ public onESignSignPdfSuccess(callback: (data: { response: string }) => void) {
736
+ return this.sdk.onESignSignPdfSuccess(callback);
737
+ }
738
+
739
+ public onESignSendConfirmationDocumentSuccess(callback: (data: { response: string }) => void) {
740
+ return this.sdk.onESignSendConfirmationDocumentSuccess(callback);
741
+ }
742
+
743
+ public onESignError(callback: (error: ESignError) => void) {
744
+ return this.sdk.onESignError(callback);
745
+ }
746
+
333
747
  /**
334
748
  * Start eKYC UI with flow (like MainActivity.kt)
335
749
  * @param appKey Main app key
@@ -439,8 +853,162 @@ export class FinosEKYCModule {
439
853
  }
440
854
  }
441
855
 
442
- // Export singleton instance
443
- export const FinosEKYC = FinosEKYCModule.getInstance();
856
+ // Export singleton instance - ensure it's always initialized
857
+ let _finosEKYCInstance: FinosEKYCModule | null = null;
858
+
859
+ const getFinosEKYCInstance = (): FinosEKYCModule => {
860
+ if (!_finosEKYCInstance) {
861
+ try {
862
+ _finosEKYCInstance = FinosEKYCModule.getInstance();
863
+ } catch (error) {
864
+ console.error('Failed to initialize FinosEKYCModule:', error);
865
+ throw new Error('FinosEKYCModule initialization failed. Please check native module setup.');
866
+ }
867
+ }
868
+ return _finosEKYCInstance;
869
+ };
870
+
871
+ // Initialize immediately
872
+ try {
873
+ _finosEKYCInstance = FinosEKYCModule.getInstance();
874
+ } catch (error) {
875
+ // Silent initialization - will be created on first access
876
+ }
877
+
878
+ // Helper to check if a property is a method on FinosEKYCModule
879
+ const isMethod = (prop: string | symbol): boolean => {
880
+ if (typeof prop !== 'string') return false;
881
+ // Check if it's a known method from the class
882
+ const prototype = FinosEKYCModule.prototype as any;
883
+ return typeof prototype[prop] === 'function' ||
884
+ prop.startsWith('on') ||
885
+ prop === 'initialize' ||
886
+ prop === 'startEkycUI' ||
887
+ prop === 'startNfcScan' ||
888
+ prop === 'checkC06' ||
889
+ prop === 'startOcr' ||
890
+ prop === 'startLiveness' ||
891
+ prop === 'startFaceCompare';
892
+ };
893
+
894
+ // Create a comprehensive stub object with all methods to prevent undefined errors
895
+ const createFinosEKYCStub = (): FinosEKYCModule => {
896
+ const stub = {} as any;
897
+
898
+ // Add all event listener methods (on* methods)
899
+ const eventListenerMethods = [
900
+ 'onNfcScanStart', 'onNfcScanSuccess', 'onNfcError',
901
+ 'onC06Success', 'onC06Error',
902
+ 'onOCRSuccess', 'onOCRError',
903
+ 'onLivenessSuccess', 'onLivenessError',
904
+ 'onFaceCompareSuccess', 'onFaceCompareError',
905
+ 'onSmsOtpSendSuccess', 'onSmsOtpVerifySuccess', 'onSmsOtpResendSuccess', 'onSmsOtpError',
906
+ 'onESignInitSuccess', 'onESignOpenSessionSuccess', 'onESignRegisterDeviceSuccess',
907
+ 'onESignListCertsSuccess', 'onESignVerifyCertSuccess', 'onESignListSignRequestSuccess',
908
+ 'onESignConfirmSignSuccess', 'onESignAuthenticateSuccess', 'onESignRegisterRemoteSigningSuccess',
909
+ 'onESignSignPdfSuccess', 'onESignSendConfirmationDocumentSuccess', 'onESignError'
910
+ ];
911
+
912
+ eventListenerMethods.forEach(method => {
913
+ stub[method] = (callback?: any) => {
914
+ console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
915
+ return null;
916
+ };
917
+ });
918
+
919
+ // Add all other methods
920
+ const otherMethods = [
921
+ 'initialize', 'startNfcScan', 'checkC06', 'startOCR', 'startLiveness', 'startFaceCompare',
922
+ 'startEkycUI', 'sendOtp', 'verifyOtp', 'resendOtp', 'initializeESign', 'openSessionId',
923
+ 'registerDevice', 'listCerts', 'verifyCert', 'listSignRequest', 'confirmSign',
924
+ 'authenticate', 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
925
+ 'onResume', 'onPause', 'isSDKReady', 'getSDKInfo'
926
+ ];
927
+
928
+ otherMethods.forEach(method => {
929
+ stub[method] = async (...args: any[]) => {
930
+ console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
931
+ throw new Error(`FinosEKYC.${method} is not available. Module may not be initialized.`);
932
+ };
933
+ });
934
+
935
+ return stub as FinosEKYCModule;
936
+ };
937
+
938
+ // Create a safe wrapper using Proxy - ensure it's always an object
939
+ const createFinosEKYCProxy = (): FinosEKYCModule => {
940
+ try {
941
+ return new Proxy({} as FinosEKYCModule, {
942
+ get(_target, prop) {
943
+ try {
944
+ const instance = getFinosEKYCInstance();
945
+ const value = (instance as any)[prop];
946
+ if (typeof value === 'function') {
947
+ return value.bind(instance);
948
+ }
949
+ return value;
950
+ } catch (error) {
951
+ console.warn(`⚠️ FinosEKYC.${String(prop)} is not available:`, error);
952
+ // Always return a function for methods to prevent "undefined" errors
953
+ if (isMethod(prop)) {
954
+ // For event listeners (on* methods), return a function that returns null
955
+ if (typeof prop === 'string' && prop.startsWith('on')) {
956
+ return (callback?: any) => {
957
+ console.warn(`⚠️ FinosEKYC.${prop} called but module is not initialized`);
958
+ return null;
959
+ };
960
+ }
961
+ // For other methods, return a no-op async function
962
+ return async (...args: any[]) => {
963
+ console.warn(`⚠️ FinosEKYC.${String(prop)} called but module is not initialized`);
964
+ throw new Error(`FinosEKYC.${String(prop)} is not available. Module may not be initialized.`);
965
+ };
966
+ }
967
+ return undefined;
968
+ }
969
+ }
970
+ });
971
+ } catch (error) {
972
+ console.error('❌ Failed to create FinosEKYC proxy:', error);
973
+ // Return a comprehensive stub object
974
+ return createFinosEKYCStub();
975
+ }
976
+ };
977
+
978
+ // Create a wrapper that always returns a valid object
979
+ // This ensures FinosEKYC is NEVER undefined and always has all methods
980
+ const createFinosEKYCWrapper = (): FinosEKYCModule => {
981
+ // Always start with stub to ensure all methods exist
982
+ const stub = createFinosEKYCStub();
983
+ const wrapper = { ...stub } as any;
984
+
985
+ // Try to get real instance and override methods
986
+ try {
987
+ const realInstance = getFinosEKYCInstance();
988
+
989
+ // Override with real instance methods
990
+ Object.getOwnPropertyNames(Object.getPrototypeOf(realInstance)).forEach(key => {
991
+ if (key !== 'constructor' && typeof (realInstance as any)[key] === 'function') {
992
+ wrapper[key] = ((realInstance as any)[key]).bind(realInstance);
993
+ }
994
+ });
995
+
996
+ // Also copy any own properties from real instance
997
+ Object.keys(realInstance).forEach(key => {
998
+ if ((realInstance as any)[key] !== undefined) {
999
+ wrapper[key] = (realInstance as any)[key];
1000
+ }
1001
+ });
1002
+ } catch (error) {
1003
+ // If we can't get instance, wrapper already has all stub methods
1004
+ // No need to do anything
1005
+ }
1006
+
1007
+ return wrapper as FinosEKYCModule;
1008
+ };
1009
+
1010
+ // Export - this ensures FinosEKYC is never undefined
1011
+ export const FinosEKYC = createFinosEKYCWrapper();
444
1012
 
445
1013
  // Export types
446
1014
  export type { NfcConfig, NfcError } from '../types/ekycNFCType';
@@ -449,6 +1017,8 @@ export type { OcrConfig } from '../types/ekycOCRType';
449
1017
  export type { LivenessConfig } from '../types/ekycLivenessType';
450
1018
  export type { FaceServiceConfig } from '../types/ekycFaceType';
451
1019
  export type { SDKEkycResultWithEvent, SDKEkycResultStringWithEvent } from '../types/ekycType';
1020
+ export type { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';
1021
+ export type { UserEsignModel, ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
452
1022
 
453
1023
  // Export constants
454
1024
  export { SDK_VERSION, SDK_NAME };