@finos_sdk/sdk-ekyc 1.2.8 → 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
  }
@@ -110,6 +110,24 @@ export class FinosEKYCModule {
110
110
  return this.isInitialized && this.sdk.isSDKInitialized();
111
111
  }
112
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
+
113
131
  /**
114
132
  * Start NFC scanning for Vietnamese CCCD
115
133
  * @param config NFC configuration
@@ -117,7 +135,7 @@ export class FinosEKYCModule {
117
135
  public async startNfcScan(config: NfcConfig): Promise<SDKEkycResultStringWithEvent> {
118
136
  this.validateSDKReady();
119
137
  this.validatePlatform('android', 'NFC scanning is only available on Android');
120
-
138
+
121
139
  try {
122
140
  console.log('📡 Starting NFC scan...');
123
141
  const result = await this.sdk.startNfcScan(config);
@@ -135,7 +153,7 @@ export class FinosEKYCModule {
135
153
  */
136
154
  public async checkC06(config: C06Config): Promise<SDKEkycResultStringWithEvent> {
137
155
  this.validateSDKReady();
138
-
156
+
139
157
  try {
140
158
  console.log('🏠 Starting C06 residence check...');
141
159
  const result = await this.sdk.checkC06(config);
@@ -151,9 +169,9 @@ export class FinosEKYCModule {
151
169
  * Start OCR document scanning
152
170
  * @param config OCR configuration
153
171
  */
154
- public async startOCR(config: OcrConfig): Promise<SDKEkycResultStringWithEvent> {
172
+ public async startOcr(config: OcrConfig): Promise<SDKEkycResultStringWithEvent> {
155
173
  this.validateSDKReady();
156
-
174
+
157
175
  try {
158
176
  console.log('📄 Starting OCR scan...');
159
177
  const result = await this.sdk.startOcr(config);
@@ -167,16 +185,33 @@ export class FinosEKYCModule {
167
185
 
168
186
  /**
169
187
  * Start liveness detection
170
- * @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)
171
195
  */
172
196
  public async startLiveness(config: LivenessConfig): Promise<SDKEkycResultStringWithEvent> {
173
197
  this.validateSDKReady();
174
-
198
+
175
199
  try {
176
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
+ }
177
209
  if (config.switchFrontCamera !== undefined) {
178
210
  console.log('📷 Front camera setting:', config.switchFrontCamera ? 'ON' : 'OFF');
179
211
  }
212
+
213
+
214
+
180
215
  const result = await this.sdk.startLiveness(config);
181
216
  console.log('✅ Liveness detection completed:', result.event);
182
217
  return result;
@@ -192,7 +227,7 @@ export class FinosEKYCModule {
192
227
  */
193
228
  public async startFaceCompare(config: FaceServiceConfig): Promise<SDKEkycResultStringWithEvent> {
194
229
  this.validateSDKReady();
195
-
230
+
196
231
  try {
197
232
  console.log('👤 Starting face comparison...');
198
233
  const result = await this.sdk.startFaceCompare(config);
@@ -210,7 +245,7 @@ export class FinosEKYCModule {
210
245
  */
211
246
  public async extractNfcDataForC06(nfcResultJson: string): Promise<any> {
212
247
  this.validateSDKReady();
213
-
248
+
214
249
  try {
215
250
  console.log('🔍 Extracting NFC data for C06...');
216
251
  // Note: This method needs to be implemented in the native module
@@ -285,14 +320,14 @@ export class FinosEKYCModule {
285
320
  /**
286
321
  * Listen for OCR success events
287
322
  */
288
- public onOCRSuccess(callback: (data: SDKEkycResultStringWithEvent) => void) {
323
+ public onOcrSuccess(callback: (data: SDKEkycResultStringWithEvent) => void) {
289
324
  return this.sdk.onOcrSuccess(callback);
290
325
  }
291
326
 
292
327
  /**
293
328
  * Listen for OCR error events
294
329
  */
295
- public onOCRError(callback: (error: any) => void) {
330
+ public onOcrError(callback: (error: any) => void) {
296
331
  return this.sdk.onOcrError(callback);
297
332
  }
298
333
 
@@ -340,7 +375,7 @@ export class FinosEKYCModule {
340
375
  */
341
376
  public async sendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
342
377
  this.validateSDKReady();
343
-
378
+
344
379
  try {
345
380
  console.log('📱 Sending SMS OTP...');
346
381
  const result = await this.sdk.sendOtp(config);
@@ -359,7 +394,7 @@ export class FinosEKYCModule {
359
394
  */
360
395
  public async verifyOtp(config: SmsOtpConfig, otpCode: string): Promise<SmsOtpResult> {
361
396
  this.validateSDKReady();
362
-
397
+
363
398
  try {
364
399
  console.log('🔐 Verifying SMS OTP...');
365
400
  const result = await this.sdk.verifyOtp(config, otpCode);
@@ -377,7 +412,7 @@ export class FinosEKYCModule {
377
412
  */
378
413
  public async resendOtp(config: SmsOtpConfig): Promise<SmsOtpResult> {
379
414
  this.validateSDKReady();
380
-
415
+
381
416
  try {
382
417
  console.log('📱 Resending SMS OTP...');
383
418
  const result = await this.sdk.resendOtp(config);
@@ -398,14 +433,6 @@ export class FinosEKYCModule {
398
433
  return listener;
399
434
  }
400
435
 
401
- public onSmsOtpVerifySuccess(callback: (data: SmsOtpResult) => void) {
402
- const listener = this.sdk.onSmsOtpVerifySuccess(callback);
403
- if (!listener) {
404
- console.warn('⚠️ onSmsOtpVerifySuccess: Event emitter not ready.');
405
- }
406
- return listener;
407
- }
408
-
409
436
  public onSmsOtpResendSuccess(callback: (data: SmsOtpResult) => void) {
410
437
  const listener = this.sdk.onSmsOtpResendSuccess(callback);
411
438
  if (!listener) {
@@ -429,7 +456,7 @@ export class FinosEKYCModule {
429
456
  */
430
457
  public async initializeESign(): Promise<ESignInitResult> {
431
458
  this.validateSDKReady();
432
-
459
+
433
460
  try {
434
461
  console.log('🔐 Initializing eSign SDK...');
435
462
  const result = await this.sdk.initializeESign();
@@ -457,7 +484,7 @@ export class FinosEKYCModule {
457
484
  privateKeyFilePath?: string
458
485
  ): Promise<ESignOpenSessionResult> {
459
486
  this.validateSDKReady();
460
-
487
+
461
488
  try {
462
489
  console.log('🔓 Opening eSign session...');
463
490
  const result = await this.sdk.openSessionId(
@@ -487,7 +514,7 @@ export class FinosEKYCModule {
487
514
  fcmToken?: string
488
515
  ): Promise<{ code: string; message: string }> {
489
516
  this.validateSDKReady();
490
-
517
+
491
518
  try {
492
519
  console.log('📱 Registering eSign device...');
493
520
  const result = await this.sdk.registerDevice(recoverCode, pinCode, fcmToken);
@@ -509,7 +536,7 @@ export class FinosEKYCModule {
509
536
  pageSize: number = 10
510
537
  ): Promise<{ certs: ESignCertificate[] }> {
511
538
  this.validateSDKReady();
512
-
539
+
513
540
  try {
514
541
  console.log('📋 Listing eSign certificates...');
515
542
  const result = await this.sdk.listCerts(pageNumber, pageSize);
@@ -527,7 +554,7 @@ export class FinosEKYCModule {
527
554
  */
528
555
  public async verifyCert(serial: string): Promise<{ code: string; message: string }> {
529
556
  this.validateSDKReady();
530
-
557
+
531
558
  try {
532
559
  console.log('✅ Verifying eSign certificate...');
533
560
  const result = await this.sdk.verifyCert(serial);
@@ -549,7 +576,7 @@ export class FinosEKYCModule {
549
576
  pageSize: number = 10
550
577
  ): Promise<{ requests: ESignSignRequest[] }> {
551
578
  this.validateSDKReady();
552
-
579
+
553
580
  try {
554
581
  console.log('📋 Listing eSign sign requests...');
555
582
  const result = await this.sdk.listSignRequest(pageNumber, pageSize);
@@ -577,7 +604,7 @@ export class FinosEKYCModule {
577
604
  confirm: boolean = true
578
605
  ): Promise<{ code: string; message: string }> {
579
606
  this.validateSDKReady();
580
-
607
+
581
608
  try {
582
609
  console.log('✍️ Confirming eSign signature...');
583
610
  const result = await this.sdk.confirmSign(signRequestId, pinCode, authId, authData, confirm);
@@ -589,27 +616,7 @@ export class FinosEKYCModule {
589
616
  }
590
617
  }
591
618
 
592
- /**
593
- * Authenticate with eSign
594
- * @param username eSign username
595
- * @param password eSign password
596
- */
597
- public async authenticate(
598
- username: string,
599
- password: string
600
- ): Promise<ESignAuthenticateResult> {
601
- this.validateSDKReady();
602
-
603
- try {
604
- console.log('🔐 Authenticating with eSign...');
605
- const result = await this.sdk.authenticate(username, password);
606
- console.log('✅ eSign authentication successful');
607
- return result;
608
- } catch (error) {
609
- console.error('❌ eSign authentication failed:', error);
610
- throw error;
611
- }
612
- }
619
+
613
620
 
614
621
  /**
615
622
  * Register remote signing certificate
@@ -617,14 +624,13 @@ export class FinosEKYCModule {
617
624
  * @param requestJson JSON request body
618
625
  */
619
626
  public async registerRemoteSigning(
620
- accessToken: string,
621
627
  requestJson: string
622
628
  ): Promise<{ response: string }> {
623
629
  this.validateSDKReady();
624
-
630
+
625
631
  try {
626
632
  console.log('📝 Registering remote signing certificate...');
627
- const result = await this.sdk.registerRemoteSigning(accessToken, requestJson);
633
+ const result = await this.sdk.registerRemoteSigning(requestJson);
628
634
  console.log('✅ Remote signing certificate registered successfully');
629
635
  return result;
630
636
  } catch (error) {
@@ -639,14 +645,13 @@ export class FinosEKYCModule {
639
645
  * @param requestJson JSON request body
640
646
  */
641
647
  public async signPdf(
642
- accessToken: string,
643
648
  requestJson: string
644
649
  ): Promise<{ response: string }> {
645
650
  this.validateSDKReady();
646
-
651
+
647
652
  try {
648
653
  console.log('📄 Signing PDF document...');
649
- const result = await this.sdk.signPdf(accessToken, requestJson);
654
+ const result = await this.sdk.signPdf(requestJson);
650
655
  console.log('✅ PDF document signed successfully');
651
656
  return result;
652
657
  } catch (error) {
@@ -661,14 +666,13 @@ export class FinosEKYCModule {
661
666
  * @param requestJson JSON string containing request data
662
667
  */
663
668
  public async sendConfirmationDocument(
664
- accessToken: string,
665
669
  requestJson: string
666
670
  ): Promise<{ response: string }> {
667
671
  this.validateSDKReady();
668
-
672
+
669
673
  try {
670
674
  console.log('📧 Sending confirmation document...');
671
- const result = await this.sdk.sendConfirmationDocument(accessToken, requestJson);
675
+ const result = await this.sdk.sendConfirmationDocument(requestJson);
672
676
  console.log('✅ Confirmation document sent successfully');
673
677
  return result;
674
678
  } catch (error) {
@@ -706,9 +710,7 @@ export class FinosEKYCModule {
706
710
  return this.sdk.onESignConfirmSignSuccess(callback);
707
711
  }
708
712
 
709
- public onESignAuthenticateSuccess(callback: (data: ESignAuthenticateResult) => void) {
710
- return this.sdk.onESignAuthenticateSuccess(callback);
711
- }
713
+
712
714
 
713
715
  public onESignRegisterRemoteSigningSuccess(callback: (data: { response: string }) => void) {
714
716
  return this.sdk.onESignRegisterRemoteSigningSuccess(callback);
@@ -794,7 +796,7 @@ export class FinosEKYCModule {
794
796
  }
795
797
  ): Promise<any> {
796
798
  this.validateSDKReady();
797
-
799
+
798
800
  try {
799
801
  console.log('🚀 Starting eKYC UI with flow:', flowSDK);
800
802
  console.log('🔧 OptionConfig:', optionConfig);
@@ -803,7 +805,7 @@ export class FinosEKYCModule {
803
805
  }
804
806
  console.log('🔑 AppKeyConfig:', appKeyConfig);
805
807
  console.log('🎨 StyleConfig:', styleConfig);
806
-
808
+
807
809
  const result = await this.sdk.startEkycUI(
808
810
  appKey,
809
811
  flowSDK,
@@ -862,58 +864,58 @@ const isMethod = (prop: string | symbol): boolean => {
862
864
  if (typeof prop !== 'string') return false;
863
865
  // Check if it's a known method from the class
864
866
  const prototype = FinosEKYCModule.prototype as any;
865
- return typeof prototype[prop] === 'function' ||
866
- prop.startsWith('on') ||
867
- prop === 'initialize' ||
868
- prop === 'startEkycUI' ||
869
- prop === 'startNfcScan' ||
870
- prop === 'checkC06' ||
871
- prop === 'startOcr' ||
872
- prop === 'startLiveness' ||
873
- 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';
874
876
  };
875
877
 
876
878
  // Create a comprehensive stub object with all methods to prevent undefined errors
877
879
  const createFinosEKYCStub = (): FinosEKYCModule => {
878
880
  const stub = {} as any;
879
-
881
+
880
882
  // Add all event listener methods (on* methods)
881
883
  const eventListenerMethods = [
882
884
  'onNfcScanStart', 'onNfcScanSuccess', 'onNfcError',
883
885
  'onC06Success', 'onC06Error',
884
- 'onOCRSuccess', 'onOCRError',
886
+ 'onOcrSuccess', 'onOcrError',
885
887
  'onLivenessSuccess', 'onLivenessError',
886
888
  'onFaceCompareSuccess', 'onFaceCompareError',
887
889
  'onSmsOtpSendSuccess', 'onSmsOtpVerifySuccess', 'onSmsOtpResendSuccess', 'onSmsOtpError',
888
890
  'onESignInitSuccess', 'onESignOpenSessionSuccess', 'onESignRegisterDeviceSuccess',
889
891
  'onESignListCertsSuccess', 'onESignVerifyCertSuccess', 'onESignListSignRequestSuccess',
890
- 'onESignConfirmSignSuccess', 'onESignAuthenticateSuccess', 'onESignRegisterRemoteSigningSuccess',
892
+ 'onESignConfirmSignSuccess', 'onESignRegisterRemoteSigningSuccess',
891
893
  'onESignSignPdfSuccess', 'onESignSendConfirmationDocumentSuccess', 'onESignError'
892
894
  ];
893
-
895
+
894
896
  eventListenerMethods.forEach(method => {
895
897
  stub[method] = (callback?: any) => {
896
898
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
897
899
  return null;
898
900
  };
899
901
  });
900
-
902
+
901
903
  // Add all other methods
902
904
  const otherMethods = [
903
- 'initialize', 'startNfcScan', 'checkC06', 'startOCR', 'startLiveness', 'startFaceCompare',
905
+ 'initialize', 'startNfcScan', 'checkC06', 'startOcr', 'startLiveness', 'startFaceCompare',
904
906
  'startEkycUI', 'sendOtp', 'verifyOtp', 'resendOtp', 'initializeESign', 'openSessionId',
905
907
  'registerDevice', 'listCerts', 'verifyCert', 'listSignRequest', 'confirmSign',
906
- 'authenticate', 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
908
+ 'registerRemoteSigning', 'signPdf', 'sendConfirmationDocument',
907
909
  'onResume', 'onPause', 'isSDKReady', 'getSDKInfo'
908
910
  ];
909
-
911
+
910
912
  otherMethods.forEach(method => {
911
913
  stub[method] = async (...args: any[]) => {
912
914
  console.warn(`⚠️ FinosEKYC.${method} called but module is not initialized`);
913
915
  throw new Error(`FinosEKYC.${method} is not available. Module may not be initialized.`);
914
916
  };
915
917
  });
916
-
918
+
917
919
  return stub as FinosEKYCModule;
918
920
  };
919
921
 
@@ -963,18 +965,18 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
963
965
  // Always start with stub to ensure all methods exist
964
966
  const stub = createFinosEKYCStub();
965
967
  const wrapper = { ...stub } as any;
966
-
968
+
967
969
  // Try to get real instance and override methods
968
970
  try {
969
971
  const realInstance = getFinosEKYCInstance();
970
-
972
+
971
973
  // Override with real instance methods
972
974
  Object.getOwnPropertyNames(Object.getPrototypeOf(realInstance)).forEach(key => {
973
975
  if (key !== 'constructor' && typeof (realInstance as any)[key] === 'function') {
974
976
  wrapper[key] = ((realInstance as any)[key]).bind(realInstance);
975
977
  }
976
978
  });
977
-
979
+
978
980
  // Also copy any own properties from real instance
979
981
  Object.keys(realInstance).forEach(key => {
980
982
  if ((realInstance as any)[key] !== undefined) {
@@ -985,7 +987,7 @@ const createFinosEKYCWrapper = (): FinosEKYCModule => {
985
987
  // If we can't get instance, wrapper already has all stub methods
986
988
  // No need to do anything
987
989
  }
988
-
990
+
989
991
  return wrapper as FinosEKYCModule;
990
992
  };
991
993
 
@@ -997,6 +999,7 @@ export type { NfcConfig, NfcError } from '../types/ekycNFCType';
997
999
  export type { C06Config } from '../types/ekycC06Type';
998
1000
  export type { OcrConfig } from '../types/ekycOCRType';
999
1001
  export type { LivenessConfig } from '../types/ekycLivenessType';
1002
+ export { SDKFaceDetectStatus } from '../types/ekycLivenessType';
1000
1003
  export type { FaceServiceConfig } from '../types/ekycFaceType';
1001
1004
  export type { SDKEkycResultWithEvent, SDKEkycResultStringWithEvent } from '../types/ekycType';
1002
1005
  export type { SmsOtpConfig, SmsOtpResult, SmsOtpError } from '../types/ekycSmsOtpType';