@finos_sdk/sdk-ekyc 1.2.9 → 1.3.2

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.
@@ -7,7 +7,7 @@ import { OcrConfig } from '../types/ekycOCRType';
7
7
  import { LivenessConfig } from '../types/ekycLivenessType';
8
8
  import { FaceServiceConfig } from '../types/ekycFaceType';
9
9
  import { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';
10
- import { UserEsignModel, ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
10
+ import { ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
11
11
 
12
12
  /**
13
13
  * Finos eKYC SDK Module
@@ -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();
@@ -458,41 +467,31 @@ export class FinosEKYCModule {
458
467
  throw error;
459
468
  }
460
469
  }
461
-
462
470
  /**
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)
471
+ * Open eSign Session
472
+ * @param accessToken Access token (JWT)
473
+ * @param username Username
474
+ * @param rememberMe Remember me flag
475
+ * @param userEsignModel User info model (for auto-token generation)
476
+ * @param privateKeyFilePath Path to private key file (for auto-token generation)
469
477
  */
470
478
  public async openSessionId(
471
- accessToken?: string,
472
- username?: string,
473
- rememberMe?: boolean,
474
- userEsignModel?: UserEsignModel,
475
- privateKeyFilePath?: string
479
+ accessToken: string | null,
480
+ username: string | null,
481
+ rememberMe: boolean | null
476
482
  ): Promise<ESignOpenSessionResult> {
477
483
  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
- }
484
+ // Pass through to SDK - error handling is done in EKYCModule.ts
485
+ return await this.sdk.openSessionId(
486
+ accessToken,
487
+ username,
488
+ rememberMe
489
+ );
494
490
  }
495
491
 
492
+
493
+
494
+
496
495
  /**
497
496
  * Register device for eSign
498
497
  * @param recoverCode 8-digit recovery code
@@ -505,7 +504,7 @@ export class FinosEKYCModule {
505
504
  fcmToken?: string
506
505
  ): Promise<{ code: string; message: string }> {
507
506
  this.validateSDKReady();
508
-
507
+
509
508
  try {
510
509
  console.log('📱 Registering eSign device...');
511
510
  const result = await this.sdk.registerDevice(recoverCode, pinCode, fcmToken);
@@ -527,7 +526,7 @@ export class FinosEKYCModule {
527
526
  pageSize: number = 10
528
527
  ): Promise<{ certs: ESignCertificate[] }> {
529
528
  this.validateSDKReady();
530
-
529
+
531
530
  try {
532
531
  console.log('📋 Listing eSign certificates...');
533
532
  const result = await this.sdk.listCerts(pageNumber, pageSize);
@@ -545,7 +544,7 @@ export class FinosEKYCModule {
545
544
  */
546
545
  public async verifyCert(serial: string): Promise<{ code: string; message: string }> {
547
546
  this.validateSDKReady();
548
-
547
+
549
548
  try {
550
549
  console.log('✅ Verifying eSign certificate...');
551
550
  const result = await this.sdk.verifyCert(serial);
@@ -567,7 +566,7 @@ export class FinosEKYCModule {
567
566
  pageSize: number = 10
568
567
  ): Promise<{ requests: ESignSignRequest[] }> {
569
568
  this.validateSDKReady();
570
-
569
+
571
570
  try {
572
571
  console.log('📋 Listing eSign sign requests...');
573
572
  const result = await this.sdk.listSignRequest(pageNumber, pageSize);
@@ -595,7 +594,7 @@ export class FinosEKYCModule {
595
594
  confirm: boolean = true
596
595
  ): Promise<{ code: string; message: string }> {
597
596
  this.validateSDKReady();
598
-
597
+
599
598
  try {
600
599
  console.log('✍️ Confirming eSign signature...');
601
600
  const result = await this.sdk.confirmSign(signRequestId, pinCode, authId, authData, confirm);
@@ -607,27 +606,7 @@ export class FinosEKYCModule {
607
606
  }
608
607
  }
609
608
 
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
- }
609
+
631
610
 
632
611
  /**
633
612
  * Register remote signing certificate
@@ -635,14 +614,13 @@ export class FinosEKYCModule {
635
614
  * @param requestJson JSON request body
636
615
  */
637
616
  public async registerRemoteSigning(
638
- accessToken: string,
639
617
  requestJson: string
640
618
  ): Promise<{ response: string }> {
641
619
  this.validateSDKReady();
642
-
620
+
643
621
  try {
644
622
  console.log('📝 Registering remote signing certificate...');
645
- const result = await this.sdk.registerRemoteSigning(accessToken, requestJson);
623
+ const result = await this.sdk.registerRemoteSigning(requestJson);
646
624
  console.log('✅ Remote signing certificate registered successfully');
647
625
  return result;
648
626
  } catch (error) {
@@ -657,14 +635,13 @@ export class FinosEKYCModule {
657
635
  * @param requestJson JSON request body
658
636
  */
659
637
  public async signPdf(
660
- accessToken: string,
661
638
  requestJson: string
662
639
  ): Promise<{ response: string }> {
663
640
  this.validateSDKReady();
664
-
641
+
665
642
  try {
666
643
  console.log('📄 Signing PDF document...');
667
- const result = await this.sdk.signPdf(accessToken, requestJson);
644
+ const result = await this.sdk.signPdf(requestJson);
668
645
  console.log('✅ PDF document signed successfully');
669
646
  return result;
670
647
  } catch (error) {
@@ -679,14 +656,13 @@ export class FinosEKYCModule {
679
656
  * @param requestJson JSON string containing request data
680
657
  */
681
658
  public async sendConfirmationDocument(
682
- accessToken: string,
683
659
  requestJson: string
684
660
  ): Promise<{ response: string }> {
685
661
  this.validateSDKReady();
686
-
662
+
687
663
  try {
688
664
  console.log('📧 Sending confirmation document...');
689
- const result = await this.sdk.sendConfirmationDocument(accessToken, requestJson);
665
+ const result = await this.sdk.sendConfirmationDocument(requestJson);
690
666
  console.log('✅ Confirmation document sent successfully');
691
667
  return result;
692
668
  } catch (error) {
@@ -724,9 +700,7 @@ export class FinosEKYCModule {
724
700
  return this.sdk.onESignConfirmSignSuccess(callback);
725
701
  }
726
702
 
727
- public onESignAuthenticateSuccess(callback: (data: ESignAuthenticateResult) => void) {
728
- return this.sdk.onESignAuthenticateSuccess(callback);
729
- }
703
+
730
704
 
731
705
  public onESignRegisterRemoteSigningSuccess(callback: (data: { response: string }) => void) {
732
706
  return this.sdk.onESignRegisterRemoteSigningSuccess(callback);
@@ -812,7 +786,7 @@ export class FinosEKYCModule {
812
786
  }
813
787
  ): Promise<any> {
814
788
  this.validateSDKReady();
815
-
789
+
816
790
  try {
817
791
  console.log('🚀 Starting eKYC UI with flow:', flowSDK);
818
792
  console.log('🔧 OptionConfig:', optionConfig);
@@ -821,7 +795,7 @@ export class FinosEKYCModule {
821
795
  }
822
796
  console.log('🔑 AppKeyConfig:', appKeyConfig);
823
797
  console.log('🎨 StyleConfig:', styleConfig);
824
-
798
+
825
799
  const result = await this.sdk.startEkycUI(
826
800
  appKey,
827
801
  flowSDK,
@@ -880,58 +854,59 @@ const isMethod = (prop: string | symbol): boolean => {
880
854
  if (typeof prop !== 'string') return false;
881
855
  // Check if it's a known method from the class
882
856
  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';
857
+ return typeof prototype[prop] === 'function' ||
858
+ prop.startsWith('on') ||
859
+ prop === 'initialize' ||
860
+ prop === 'openSessionId' ||
861
+ prop === 'startEkycUI' ||
862
+ prop === 'startNfcScan' ||
863
+ prop === 'checkC06' ||
864
+ prop === 'startOcr' ||
865
+ prop === 'startLiveness' ||
866
+ prop === 'startFaceCompare';
892
867
  };
893
868
 
894
869
  // Create a comprehensive stub object with all methods to prevent undefined errors
895
870
  const createFinosEKYCStub = (): FinosEKYCModule => {
896
871
  const stub = {} as any;
897
-
872
+
898
873
  // Add all event listener methods (on* methods)
899
874
  const eventListenerMethods = [
900
875
  'onNfcScanStart', 'onNfcScanSuccess', 'onNfcError',
901
876
  'onC06Success', 'onC06Error',
902
- 'onOCRSuccess', 'onOCRError',
877
+ 'onOcrSuccess', 'onOcrError',
903
878
  'onLivenessSuccess', 'onLivenessError',
904
879
  'onFaceCompareSuccess', 'onFaceCompareError',
905
880
  'onSmsOtpSendSuccess', 'onSmsOtpVerifySuccess', 'onSmsOtpResendSuccess', 'onSmsOtpError',
906
881
  'onESignInitSuccess', 'onESignOpenSessionSuccess', 'onESignRegisterDeviceSuccess',
907
882
  'onESignListCertsSuccess', 'onESignVerifyCertSuccess', 'onESignListSignRequestSuccess',
908
- 'onESignConfirmSignSuccess', 'onESignAuthenticateSuccess', 'onESignRegisterRemoteSigningSuccess',
883
+ 'onESignConfirmSignSuccess', 'onESignRegisterRemoteSigningSuccess',
909
884
  'onESignSignPdfSuccess', 'onESignSendConfirmationDocumentSuccess', 'onESignError'
910
885
  ];
911
-
886
+
912
887
  eventListenerMethods.forEach(method => {
913
888
  stub[method] = (callback?: any) => {
914
889
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
915
890
  return null;
916
891
  };
917
892
  });
918
-
893
+
919
894
  // Add all other methods
920
895
  const otherMethods = [
921
- 'initialize', 'startNfcScan', 'checkC06', 'startOCR', 'startLiveness', 'startFaceCompare',
896
+ 'initialize', 'startNfcScan', 'checkC06', 'startOcr', 'startLiveness', 'startFaceCompare',
922
897
  'startEkycUI', 'sendOtp', 'verifyOtp', 'resendOtp', 'initializeESign', 'openSessionId',
923
898
  'registerDevice', 'listCerts', 'verifyCert', 'listSignRequest', 'confirmSign',
924
- 'authenticate', 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
899
+ 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
925
900
  'onResume', 'onPause', 'isSDKReady', 'getSDKInfo'
926
901
  ];
927
-
902
+
928
903
  otherMethods.forEach(method => {
929
904
  stub[method] = async (...args: any[]) => {
930
905
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
931
906
  throw new Error(`FinosEKYC.${method} is not available. Module may not be initialized.`);
932
907
  };
933
908
  });
934
-
909
+
935
910
  return stub as FinosEKYCModule;
936
911
  };
937
912
 
@@ -981,18 +956,18 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
981
956
  // Always start with stub to ensure all methods exist
982
957
  const stub = createFinosEKYCStub();
983
958
  const wrapper = { ...stub } as any;
984
-
959
+
985
960
  // Try to get real instance and override methods
986
961
  try {
987
962
  const realInstance = getFinosEKYCInstance();
988
-
963
+
989
964
  // Override with real instance methods
990
965
  Object.getOwnPropertyNames(Object.getPrototypeOf(realInstance)).forEach(key => {
991
966
  if (key !== 'constructor' && typeof (realInstance as any)[key] === 'function') {
992
967
  wrapper[key] = ((realInstance as any)[key]).bind(realInstance);
993
968
  }
994
969
  });
995
-
970
+
996
971
  // Also copy any own properties from real instance
997
972
  Object.keys(realInstance).forEach(key => {
998
973
  if ((realInstance as any)[key] !== undefined) {
@@ -1003,7 +978,7 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
1003
978
  // If we can't get instance, wrapper already has all stub methods
1004
979
  // No need to do anything
1005
980
  }
1006
-
981
+
1007
982
  return wrapper as FinosEKYCModule;
1008
983
  };
1009
984
 
@@ -1015,10 +990,11 @@ export type { NfcConfig, NfcError } from '../types/ekycNFCType';
1015
990
  export type { C06Config } from '../types/ekycC06Type';
1016
991
  export type { OcrConfig } from '../types/ekycOCRType';
1017
992
  export type { LivenessConfig } from '../types/ekycLivenessType';
993
+ export { SDKFaceDetectStatus } from '../types/ekycLivenessType';
1018
994
  export type { FaceServiceConfig } from '../types/ekycFaceType';
1019
995
  export type { SDKEkycResultWithEvent, SDKEkycResultStringWithEvent } from '../types/ekycType';
1020
996
  export type { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';
1021
- export type { UserEsignModel, ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
997
+ export type { ESignInitResult, ESignOpenSessionResult, ESignCertificate, ESignSignRequest, ESignError, ESignAuthenticateResult } from '../types/ekycESignType';
1022
998
 
1023
999
  // Export constants
1024
1000
  export { SDK_VERSION, SDK_NAME };