@finos_sdk/sdk-ekyc 1.2.9 → 1.3.1

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.
@@ -97,7 +97,7 @@ export class FinosEKYCModule {
97
97
  this.isInitialized = true;
98
98
  return 'SDK already initialized (Koin Application started)';
99
99
  }
100
-
100
+
101
101
  console.error('❌ Failed to initialize Finos eKYC SDK:', error);
102
102
  throw new Error(`SDK initialization failed: ${error}`);
103
103
  }
@@ -116,7 +116,7 @@ export class FinosEKYCModule {
116
116
  */
117
117
  public async setTransactionId(transactionId: string): Promise<boolean> {
118
118
  this.validateSDKReady();
119
-
119
+
120
120
  try {
121
121
  console.log('🆔 Setting transaction ID:', transactionId);
122
122
  const result = await this.sdk.setTransactionId(transactionId);
@@ -135,7 +135,7 @@ export class FinosEKYCModule {
135
135
  public async startNfcScan(config: NfcConfig): Promise<SDKEkycResultStringWithEvent> {
136
136
  this.validateSDKReady();
137
137
  this.validatePlatform('android', 'NFC scanning is only available on Android');
138
-
138
+
139
139
  try {
140
140
  console.log('📡 Starting NFC scan...');
141
141
  const result = await this.sdk.startNfcScan(config);
@@ -153,7 +153,7 @@ export class FinosEKYCModule {
153
153
  */
154
154
  public async checkC06(config: C06Config): Promise<SDKEkycResultStringWithEvent> {
155
155
  this.validateSDKReady();
156
-
156
+
157
157
  try {
158
158
  console.log('🏠 Starting C06 residence check...');
159
159
  const result = await this.sdk.checkC06(config);
@@ -169,9 +169,9 @@ export class FinosEKYCModule {
169
169
  * Start OCR document scanning
170
170
  * @param config OCR configuration
171
171
  */
172
- public async startOCR(config: OcrConfig): Promise<SDKEkycResultStringWithEvent> {
172
+ public async startOcr(config: OcrConfig): Promise<SDKEkycResultStringWithEvent> {
173
173
  this.validateSDKReady();
174
-
174
+
175
175
  try {
176
176
  console.log('📄 Starting OCR scan...');
177
177
  const result = await this.sdk.startOcr(config);
@@ -185,16 +185,33 @@ export class FinosEKYCModule {
185
185
 
186
186
  /**
187
187
  * Start liveness detection
188
- * @param config Liveness configuration (includes switchFrontCamera for camera control)
188
+ * @param config Liveness configuration
189
+ * @param config.isActiveLiveness - Enable active liveness detection (default: false)
190
+ * @param config.autoCapture - Enable auto capture (default: true)
191
+ * @param config.isShowCameraFont - Show camera font (default: true)
192
+ * @param config.customActions - Custom actions array (LEFT, RIGHT, STRAIGHT). If provided, uses these actions instead of random
193
+ * @param config.activeActionCount - Number of random actions (1-10), only used when customActions is null (default: 2)
194
+ * @param config.switchFrontCamera - Use front camera (default: false)
189
195
  */
190
196
  public async startLiveness(config: LivenessConfig): Promise<SDKEkycResultStringWithEvent> {
191
197
  this.validateSDKReady();
192
-
198
+
193
199
  try {
194
200
  console.log('👁️ Starting liveness detection...');
201
+ if (config.isActiveLiveness !== undefined) {
202
+ console.log('🔴 Active liveness:', config.isActiveLiveness ? 'ON' : 'OFF');
203
+ }
204
+ if (config.customActions && config.customActions.length > 0) {
205
+ console.log('🎯 Custom actions:', config.customActions.join(', '));
206
+ } else if (config.activeActionCount !== undefined) {
207
+ console.log('🎲 Random actions count:', config.activeActionCount);
208
+ }
195
209
  if (config.switchFrontCamera !== undefined) {
196
210
  console.log('📷 Front camera setting:', config.switchFrontCamera ? 'ON' : 'OFF');
197
211
  }
212
+
213
+
214
+
198
215
  const result = await this.sdk.startLiveness(config);
199
216
  console.log('✅ Liveness detection completed:', result.event);
200
217
  return result;
@@ -210,7 +227,7 @@ export class FinosEKYCModule {
210
227
  */
211
228
  public async startFaceCompare(config: FaceServiceConfig): Promise<SDKEkycResultStringWithEvent> {
212
229
  this.validateSDKReady();
213
-
230
+
214
231
  try {
215
232
  console.log('👤 Starting face comparison...');
216
233
  const result = await this.sdk.startFaceCompare(config);
@@ -228,7 +245,7 @@ export class FinosEKYCModule {
228
245
  */
229
246
  public async extractNfcDataForC06(nfcResultJson: string): Promise<any> {
230
247
  this.validateSDKReady();
231
-
248
+
232
249
  try {
233
250
  console.log('🔍 Extracting NFC data for C06...');
234
251
  // Note: This method needs to be implemented in the native module
@@ -303,14 +320,14 @@ export class FinosEKYCModule {
303
320
  /**
304
321
  * Listen for OCR success events
305
322
  */
306
- public onOCRSuccess(callback: (data: SDKEkycResultStringWithEvent) => void) {
323
+ public onOcrSuccess(callback: (data: SDKEkycResultStringWithEvent) => void) {
307
324
  return this.sdk.onOcrSuccess(callback);
308
325
  }
309
326
 
310
327
  /**
311
328
  * Listen for OCR error events
312
329
  */
313
- public onOCRError(callback: (error: any) => void) {
330
+ public onOcrError(callback: (error: any) => void) {
314
331
  return this.sdk.onOcrError(callback);
315
332
  }
316
333
 
@@ -358,7 +375,7 @@ export class FinosEKYCModule {
358
375
  */
359
376
  public async sendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
360
377
  this.validateSDKReady();
361
-
378
+
362
379
  try {
363
380
  console.log('📱 Sending SMS OTP...');
364
381
  const result = await this.sdk.sendOtp(config);
@@ -377,7 +394,7 @@ export class FinosEKYCModule {
377
394
  */
378
395
  public async verifyOtp(config: SmsOtpConfig, otpCode: string): Promise<SmsOtpResult> {
379
396
  this.validateSDKReady();
380
-
397
+
381
398
  try {
382
399
  console.log('🔐 Verifying SMS OTP...');
383
400
  const result = await this.sdk.verifyOtp(config, otpCode);
@@ -395,7 +412,7 @@ export class FinosEKYCModule {
395
412
  */
396
413
  public async resendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
397
414
  this.validateSDKReady();
398
-
415
+
399
416
  try {
400
417
  console.log('📱 Resending SMS OTP...');
401
418
  const result = await this.sdk.resendOtp(config);
@@ -416,14 +433,6 @@ export class FinosEKYCModule {
416
433
  return listener;
417
434
  }
418
435
 
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
436
  public onSmsOtpResendSuccess(callback: (data: SmsOtpResult) => void) {
428
437
  const listener = this.sdk.onSmsOtpResendSuccess(callback);
429
438
  if (!listener) {
@@ -447,7 +456,7 @@ export class FinosEKYCModule {
447
456
  */
448
457
  public async initializeESign(): Promise<ESignInitResult> {
449
458
  this.validateSDKReady();
450
-
459
+
451
460
  try {
452
461
  console.log('🔐 Initializing eSign SDK...');
453
462
  const result = await this.sdk.initializeESign();
@@ -475,7 +484,7 @@ export class FinosEKYCModule {
475
484
  privateKeyFilePath?: string
476
485
  ): Promise<ESignOpenSessionResult> {
477
486
  this.validateSDKReady();
478
-
487
+
479
488
  try {
480
489
  console.log('🔓 Opening eSign session...');
481
490
  const result = await this.sdk.openSessionId(
@@ -505,7 +514,7 @@ export class FinosEKYCModule {
505
514
  fcmToken?: string
506
515
  ): Promise<{ code: string; message: string }> {
507
516
  this.validateSDKReady();
508
-
517
+
509
518
  try {
510
519
  console.log('📱 Registering eSign device...');
511
520
  const result = await this.sdk.registerDevice(recoverCode, pinCode, fcmToken);
@@ -527,7 +536,7 @@ export class FinosEKYCModule {
527
536
  pageSize: number = 10
528
537
  ): Promise<{ certs: ESignCertificate[] }> {
529
538
  this.validateSDKReady();
530
-
539
+
531
540
  try {
532
541
  console.log('📋 Listing eSign certificates...');
533
542
  const result = await this.sdk.listCerts(pageNumber, pageSize);
@@ -545,7 +554,7 @@ export class FinosEKYCModule {
545
554
  */
546
555
  public async verifyCert(serial: string): Promise<{ code: string; message: string }> {
547
556
  this.validateSDKReady();
548
-
557
+
549
558
  try {
550
559
  console.log('✅ Verifying eSign certificate...');
551
560
  const result = await this.sdk.verifyCert(serial);
@@ -567,7 +576,7 @@ export class FinosEKYCModule {
567
576
  pageSize: number = 10
568
577
  ): Promise<{ requests: ESignSignRequest[] }> {
569
578
  this.validateSDKReady();
570
-
579
+
571
580
  try {
572
581
  console.log('📋 Listing eSign sign requests...');
573
582
  const result = await this.sdk.listSignRequest(pageNumber, pageSize);
@@ -595,7 +604,7 @@ export class FinosEKYCModule {
595
604
  confirm: boolean = true
596
605
  ): Promise<{ code: string; message: string }> {
597
606
  this.validateSDKReady();
598
-
607
+
599
608
  try {
600
609
  console.log('✍️ Confirming eSign signature...');
601
610
  const result = await this.sdk.confirmSign(signRequestId, pinCode, authId, authData, confirm);
@@ -607,27 +616,7 @@ export class FinosEKYCModule {
607
616
  }
608
617
  }
609
618
 
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
- }
619
+
631
620
 
632
621
  /**
633
622
  * Register remote signing certificate
@@ -635,14 +624,13 @@ export class FinosEKYCModule {
635
624
  * @param requestJson JSON request body
636
625
  */
637
626
  public async registerRemoteSigning(
638
- accessToken: string,
639
627
  requestJson: string
640
628
  ): Promise<{ response: string }> {
641
629
  this.validateSDKReady();
642
-
630
+
643
631
  try {
644
632
  console.log('📝 Registering remote signing certificate...');
645
- const result = await this.sdk.registerRemoteSigning(accessToken, requestJson);
633
+ const result = await this.sdk.registerRemoteSigning(requestJson);
646
634
  console.log('✅ Remote signing certificate registered successfully');
647
635
  return result;
648
636
  } catch (error) {
@@ -657,14 +645,13 @@ export class FinosEKYCModule {
657
645
  * @param requestJson JSON request body
658
646
  */
659
647
  public async signPdf(
660
- accessToken: string,
661
648
  requestJson: string
662
649
  ): Promise<{ response: string }> {
663
650
  this.validateSDKReady();
664
-
651
+
665
652
  try {
666
653
  console.log('📄 Signing PDF document...');
667
- const result = await this.sdk.signPdf(accessToken, requestJson);
654
+ const result = await this.sdk.signPdf(requestJson);
668
655
  console.log('✅ PDF document signed successfully');
669
656
  return result;
670
657
  } catch (error) {
@@ -679,14 +666,13 @@ export class FinosEKYCModule {
679
666
  * @param requestJson JSON string containing request data
680
667
  */
681
668
  public async sendConfirmationDocument(
682
- accessToken: string,
683
669
  requestJson: string
684
670
  ): Promise<{ response: string }> {
685
671
  this.validateSDKReady();
686
-
672
+
687
673
  try {
688
674
  console.log('📧 Sending confirmation document...');
689
- const result = await this.sdk.sendConfirmationDocument(accessToken, requestJson);
675
+ const result = await this.sdk.sendConfirmationDocument(requestJson);
690
676
  console.log('✅ Confirmation document sent successfully');
691
677
  return result;
692
678
  } catch (error) {
@@ -724,9 +710,7 @@ export class FinosEKYCModule {
724
710
  return this.sdk.onESignConfirmSignSuccess(callback);
725
711
  }
726
712
 
727
- public onESignAuthenticateSuccess(callback: (data: ESignAuthenticateResult) => void) {
728
- return this.sdk.onESignAuthenticateSuccess(callback);
729
- }
713
+
730
714
 
731
715
  public onESignRegisterRemoteSigningSuccess(callback: (data: { response: string }) => void) {
732
716
  return this.sdk.onESignRegisterRemoteSigningSuccess(callback);
@@ -812,7 +796,7 @@ export class FinosEKYCModule {
812
796
  }
813
797
  ): Promise<any> {
814
798
  this.validateSDKReady();
815
-
799
+
816
800
  try {
817
801
  console.log('🚀 Starting eKYC UI with flow:', flowSDK);
818
802
  console.log('🔧 OptionConfig:', optionConfig);
@@ -821,7 +805,7 @@ export class FinosEKYCModule {
821
805
  }
822
806
  console.log('🔑 AppKeyConfig:', appKeyConfig);
823
807
  console.log('🎨 StyleConfig:', styleConfig);
824
-
808
+
825
809
  const result = await this.sdk.startEkycUI(
826
810
  appKey,
827
811
  flowSDK,
@@ -880,58 +864,58 @@ const isMethod = (prop: string | symbol): boolean => {
880
864
  if (typeof prop !== 'string') return false;
881
865
  // Check if it's a known method from the class
882
866
  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';
867
+ return typeof prototype[prop] === 'function' ||
868
+ prop.startsWith('on') ||
869
+ prop === 'initialize' ||
870
+ prop === 'startEkycUI' ||
871
+ prop === 'startNfcScan' ||
872
+ prop === 'checkC06' ||
873
+ prop === 'startOcr' ||
874
+ prop === 'startLiveness' ||
875
+ prop === 'startFaceCompare';
892
876
  };
893
877
 
894
878
  // Create a comprehensive stub object with all methods to prevent undefined errors
895
879
  const createFinosEKYCStub = (): FinosEKYCModule => {
896
880
  const stub = {} as any;
897
-
881
+
898
882
  // Add all event listener methods (on* methods)
899
883
  const eventListenerMethods = [
900
884
  'onNfcScanStart', 'onNfcScanSuccess', 'onNfcError',
901
885
  'onC06Success', 'onC06Error',
902
- 'onOCRSuccess', 'onOCRError',
886
+ 'onOcrSuccess', 'onOcrError',
903
887
  'onLivenessSuccess', 'onLivenessError',
904
888
  'onFaceCompareSuccess', 'onFaceCompareError',
905
889
  'onSmsOtpSendSuccess', 'onSmsOtpVerifySuccess', 'onSmsOtpResendSuccess', 'onSmsOtpError',
906
890
  'onESignInitSuccess', 'onESignOpenSessionSuccess', 'onESignRegisterDeviceSuccess',
907
891
  'onESignListCertsSuccess', 'onESignVerifyCertSuccess', 'onESignListSignRequestSuccess',
908
- 'onESignConfirmSignSuccess', 'onESignAuthenticateSuccess', 'onESignRegisterRemoteSigningSuccess',
892
+ 'onESignConfirmSignSuccess', 'onESignRegisterRemoteSigningSuccess',
909
893
  'onESignSignPdfSuccess', 'onESignSendConfirmationDocumentSuccess', 'onESignError'
910
894
  ];
911
-
895
+
912
896
  eventListenerMethods.forEach(method => {
913
897
  stub[method] = (callback?: any) => {
914
898
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
915
899
  return null;
916
900
  };
917
901
  });
918
-
902
+
919
903
  // Add all other methods
920
904
  const otherMethods = [
921
- 'initialize', 'startNfcScan', 'checkC06', 'startOCR', 'startLiveness', 'startFaceCompare',
905
+ 'initialize', 'startNfcScan', 'checkC06', 'startOcr', 'startLiveness', 'startFaceCompare',
922
906
  'startEkycUI', 'sendOtp', 'verifyOtp', 'resendOtp', 'initializeESign', 'openSessionId',
923
907
  'registerDevice', 'listCerts', 'verifyCert', 'listSignRequest', 'confirmSign',
924
- 'authenticate', 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
908
+ 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
925
909
  'onResume', 'onPause', 'isSDKReady', 'getSDKInfo'
926
910
  ];
927
-
911
+
928
912
  otherMethods.forEach(method => {
929
913
  stub[method] = async (...args: any[]) => {
930
914
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
931
915
  throw new Error(`FinosEKYC.${method} is not available. Module may not be initialized.`);
932
916
  };
933
917
  });
934
-
918
+
935
919
  return stub as FinosEKYCModule;
936
920
  };
937
921
 
@@ -981,18 +965,18 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
981
965
  // Always start with stub to ensure all methods exist
982
966
  const stub = createFinosEKYCStub();
983
967
  const wrapper = { ...stub } as any;
984
-
968
+
985
969
  // Try to get real instance and override methods
986
970
  try {
987
971
  const realInstance = getFinosEKYCInstance();
988
-
972
+
989
973
  // Override with real instance methods
990
974
  Object.getOwnPropertyNames(Object.getPrototypeOf(realInstance)).forEach(key => {
991
975
  if (key !== 'constructor' && typeof (realInstance as any)[key] === 'function') {
992
976
  wrapper[key] = ((realInstance as any)[key]).bind(realInstance);
993
977
  }
994
978
  });
995
-
979
+
996
980
  // Also copy any own properties from real instance
997
981
  Object.keys(realInstance).forEach(key => {
998
982
  if ((realInstance as any)[key] !== undefined) {
@@ -1003,7 +987,7 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
1003
987
  // If we can't get instance, wrapper already has all stub methods
1004
988
  // No need to do anything
1005
989
  }
1006
-
990
+
1007
991
  return wrapper as FinosEKYCModule;
1008
992
  };
1009
993
 
@@ -1015,6 +999,7 @@ export type { NfcConfig, NfcError } from '../types/ekycNFCType';
1015
999
  export type { C06Config } from '../types/ekycC06Type';
1016
1000
  export type { OcrConfig } from '../types/ekycOCRType';
1017
1001
  export type { LivenessConfig } from '../types/ekycLivenessType';
1002
+ export { SDKFaceDetectStatus } from '../types/ekycLivenessType';
1018
1003
  export type { FaceServiceConfig } from '../types/ekycFaceType';
1019
1004
  export type { SDKEkycResultWithEvent, SDKEkycResultStringWithEvent } from '../types/ekycType';
1020
1005
  export type { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';