skyflow-js 1.6.0 → 1.7.0

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.
Binary file
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "skyflow-js",
3
3
  "preferGlobal": true,
4
4
  "analyze": false,
5
- "version": "1.6.0",
5
+ "version": "1.7.0",
6
6
  "author": "Skyflow",
7
7
  "description": "Skyflow JavaScript SDK",
8
8
  "homepage": "https://github.com/skyflowapi/skyflow-js",
@@ -41,6 +41,7 @@
41
41
  "jss-preset-default": "^10.7.1",
42
42
  "jwt-decode": "^3.1.2",
43
43
  "lodash": "^4.17.21",
44
+ "regex-parser": "^2.2.11",
44
45
  "set-value": "^4.0.1"
45
46
  },
46
47
  "engines": {
@@ -1,7 +1,7 @@
1
1
  import { ElementType } from './container/constants';
2
2
  import CollectContainer from './container/external/CollectContainer';
3
3
  import RevealContainer from './container/external/RevealContainer';
4
- import { IRevealResponseType, IConnectionConfig, RequestMethod, IInsertRecordInput, IDetokenizeInput, IGetByIdInput, RedactionType, EventName, Env, LogLevel } from './utils/common';
4
+ import { IRevealResponseType, IConnectionConfig, RequestMethod, IInsertRecordInput, IDetokenizeInput, IGetByIdInput, RedactionType, EventName, Env, LogLevel, ValidationRuleType } from './utils/common';
5
5
  export declare enum ContainerType {
6
6
  COLLECT = "COLLECT",
7
7
  REVEAL = "REVEAL"
@@ -16,7 +16,7 @@ declare class Skyflow {
16
16
  #private;
17
17
  constructor(config: ISkyflow);
18
18
  static init(config: ISkyflow): Skyflow;
19
- container(type: ContainerType, options?: Record<string, any>): CollectContainer | RevealContainer;
19
+ container(type: ContainerType, options?: Record<string, any>): RevealContainer | CollectContainer;
20
20
  insert(records: IInsertRecordInput, options?: Record<string, any>): Promise<any>;
21
21
  detokenize(detokenizeInput: IDetokenizeInput): Promise<IRevealResponseType>;
22
22
  getById(getByIdInput: IGetByIdInput): Promise<unknown>;
@@ -28,5 +28,6 @@ declare class Skyflow {
28
28
  static get LogLevel(): typeof LogLevel;
29
29
  static get EventName(): typeof EventName;
30
30
  static get Env(): typeof Env;
31
+ static get ValidationRuleType(): typeof ValidationRuleType;
31
32
  }
32
33
  export default Skyflow;
@@ -48,7 +48,8 @@ export declare enum ElementType {
48
48
  EXPIRATION_DATE = "EXPIRATION_DATE",
49
49
  CARD_NUMBER = "CARD_NUMBER",
50
50
  CARDHOLDER_NAME = "CARDHOLDER_NAME",
51
- INPUT_FIELD = "INPUT_FIELD"
51
+ INPUT_FIELD = "INPUT_FIELD",
52
+ PIN = "PIN"
52
53
  }
53
54
  export declare const ELEMENTS: {
54
55
  text: {
@@ -236,10 +237,21 @@ export declare const ELEMENTS: {
236
237
  };
237
238
  INPUT_FIELD: {
238
239
  name: string;
240
+ sensitive: boolean;
239
241
  attributes: {
240
242
  type: string;
241
243
  };
242
244
  };
245
+ PIN: {
246
+ name: string;
247
+ attributes: {
248
+ type: string;
249
+ maxLength: number;
250
+ minLength: number;
251
+ };
252
+ sensitive: boolean;
253
+ regex: RegExp;
254
+ };
243
255
  };
244
256
  export declare const IFRAME_DEFAULT_STYLES: {
245
257
  height: string;
@@ -340,40 +352,50 @@ export declare const CARD_TYPE_REGEX: {
340
352
  VISA: {
341
353
  regex: RegExp;
342
354
  maxCardLength: number;
355
+ cardLengthRange: number[];
343
356
  };
344
357
  MASTERCARD: {
345
358
  regex: RegExp;
346
359
  maxCardLength: number;
360
+ cardLengthRange: number[];
347
361
  };
348
362
  AMEX: {
349
363
  regex: RegExp;
350
364
  maxCardLength: number;
365
+ cardLengthRange: number[];
351
366
  };
352
367
  DINERS_CLUB: {
353
368
  regex: RegExp;
354
369
  maxCardLength: number;
370
+ cardLengthRange: number[];
355
371
  };
356
372
  DISCOVER: {
357
373
  regex: RegExp;
358
374
  maxCardLength: number;
375
+ cardLengthRange: number[];
359
376
  };
360
377
  JCB: {
361
378
  regex: RegExp;
362
379
  maxCardLength: number;
380
+ cardLengthRange: number[];
363
381
  };
364
382
  HIPERCARD: {
365
383
  regex: RegExp;
366
384
  maxCardLength: number;
385
+ cardLengthRange: number[];
367
386
  };
368
387
  UNIONPAY: {
369
388
  regex: RegExp;
370
389
  maxCardLength: number;
390
+ cardLengthRange: number[];
371
391
  };
372
392
  MAESTRO: {
373
393
  regex: RegExp;
374
394
  maxCardLength: number;
395
+ cardLengthRange: number[];
375
396
  };
376
397
  };
398
+ export declare const DEFAULT_CARD_LENGTH_RANGE: number[];
377
399
  export declare const CARD_ENCODED_ICONS: {
378
400
  DEFAULT: string;
379
401
  AMEX: string;
@@ -1,7 +1,7 @@
1
1
  import { ElementType } from '../constants';
2
2
  import Element from './element';
3
- import { IInsertRecordInput } from '../../utils/common';
4
- interface CollectElementInput {
3
+ import { IInsertRecordInput, IValidationRule } from '../../utils/common';
4
+ export interface CollectElementInput {
5
5
  table?: string;
6
6
  column?: string;
7
7
  inputStyles?: object;
@@ -11,6 +11,7 @@ interface CollectElementInput {
11
11
  placeholder?: string;
12
12
  type: ElementType;
13
13
  altText?: string;
14
+ validations?: IValidationRule[];
14
15
  }
15
16
  interface ICollectOptions {
16
17
  tokens?: boolean;
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from '../../../event-emitter';
2
- import { Context, LogLevel } from '../../../utils/common';
2
+ import { Context, IValidationRule, LogLevel } from '../../../utils/common';
3
3
  export declare class IFrameFormElement extends EventEmitter {
4
4
  state: {
5
5
  value: string | undefined;
@@ -16,15 +16,18 @@ export declare class IFrameFormElement extends EventEmitter {
16
16
  iFrameName: string;
17
17
  metaData: any;
18
18
  private regex?;
19
+ validations?: IValidationRule[];
20
+ errorText?: string;
19
21
  replacePattern?: [RegExp, string];
20
22
  mask?: any;
21
23
  context: Context;
22
- constructor(name: string, metaData: any, context: Context);
24
+ label?: string;
25
+ constructor(name: string, label: string, metaData: any, context: Context);
23
26
  onFocusChange: (focus: boolean) => void;
24
27
  changeFocus: (focus: boolean) => void;
25
28
  setReplacePattern(pattern: string[]): void;
26
29
  setMask(mask: string[]): void;
27
- setValidation(): void;
30
+ setValidation(validations: IValidationRule[] | undefined): void;
28
31
  setSensitive(sensitive?: boolean): void;
29
32
  setValue: (value?: string, valid?: boolean) => void;
30
33
  getValue: () => string | undefined;
@@ -37,6 +40,7 @@ export declare class IFrameFormElement extends EventEmitter {
37
40
  value: string | undefined;
38
41
  };
39
42
  validator(value: string): boolean;
43
+ validateCustomValidations(value: string): boolean;
40
44
  collectBusEvents: () => void;
41
45
  sendChangeStatus: (inputEvent?: boolean) => void;
42
46
  resetData(): void;
@@ -1,4 +1,7 @@
1
+ import { CollectElementInput } from '../container/external/CollectContainer';
2
+ import { IValidationRule } from '../utils/common';
1
3
  export declare function validateElementOptions(elementType: string, oldOptions: any, newOptions?: any): void;
2
4
  export declare function validateAndSetupGroupOptions(oldGroup: any, newGroup?: any, setup?: boolean): any;
3
5
  export declare const getElements: (group: any) => string[];
4
6
  export declare const getValueAndItsUnit: (string?: string, defaultValue?: string, defaultUnit?: string) => string[];
7
+ export declare const formatValidations: (input: CollectElementInput) => IValidationRule[] | undefined;
@@ -32,6 +32,11 @@ export declare enum MessageType {
32
32
  WARN = "WARN",
33
33
  ERROR = "ERROR"
34
34
  }
35
+ export declare enum ValidationRuleType {
36
+ REGEX_MATCH_RULE = "REGEX_MATCH_RULE",
37
+ LENGTH_MATCH_RULE = "LENGTH_MATCH_RULE",
38
+ ELEMENT_VALUE_MATCH_RULE = "ELEMENT_VALUE_MATCH_RULE"
39
+ }
35
40
  export interface IInsertRecordInput {
36
41
  records: IInsertRecord[];
37
42
  }
@@ -71,3 +76,7 @@ export interface IConnectionConfig {
71
76
  requestHeader?: any;
72
77
  responseBody?: any;
73
78
  }
79
+ export interface IValidationRule {
80
+ type: ValidationRuleType;
81
+ params: any;
82
+ }
@@ -175,5 +175,49 @@ declare const SKYFLOW_ERROR_CODE: {
175
175
  code: number;
176
176
  description: string;
177
177
  };
178
+ INVALID_VALIDATIONS_TYPE: {
179
+ code: number;
180
+ description: string;
181
+ };
182
+ MISSING_VALIDATION_RULE_TYPE: {
183
+ code: number;
184
+ description: string;
185
+ };
186
+ INVALID_VALIDATION_RULE_TYPE: {
187
+ code: number;
188
+ description: string;
189
+ };
190
+ MISSING_VALIDATION_RULE_PARAMS: {
191
+ code: number;
192
+ description: string;
193
+ };
194
+ INVALID_VALIDATION_RULE_PARAMS: {
195
+ code: number;
196
+ description: string;
197
+ };
198
+ MISSING_REGEX_IN_REGEX_MATCH_RULE: {
199
+ code: number;
200
+ description: string;
201
+ };
202
+ INVALID_REGEX_IN_REGEX_MATCH_RULE: {
203
+ code: number;
204
+ description: string;
205
+ };
206
+ MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE: {
207
+ code: number;
208
+ description: string;
209
+ };
210
+ MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE: {
211
+ code: number;
212
+ description: string;
213
+ };
214
+ INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE: {
215
+ code: number;
216
+ description: string;
217
+ };
218
+ ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE: {
219
+ code: number;
220
+ description: string;
221
+ };
178
222
  };
179
223
  export default SKYFLOW_ERROR_CODE;
@@ -131,6 +131,18 @@ declare const logs: {
131
131
  CONNECTION_ERROR: string;
132
132
  ERROR_OCCURED: string;
133
133
  RESPONSE_BODY_KEY_MISSING: string;
134
+ INVALID_VALIDATIONS_TYPE: string;
135
+ MISSING_VALIDATION_RULE_TYPE: string;
136
+ INVALID_VALIDATION_RULE_TYPE: string;
137
+ MISSING_VALIDATION_RULE_PARAMS: string;
138
+ INVALID_VALIDATION_RULE_PARAMS: string;
139
+ MISSING_REGEX_IN_REGEX_MATCH_RULE: string;
140
+ INVALID_REGEX_IN_REGEX_MATCH_RULE: string;
141
+ MISSING_MIN_AND_MAX_IN_LENGTH_MATCH_RULE: string;
142
+ MISSING_ELEMENT_IN_ELEMENT_MATCH_RULE: string;
143
+ INVALID_ELEMENT_IN_ELEMENT_MATCH_RULE: string;
144
+ ELEMENT_NOT_MOUNTED_IN_ELEMENT_MATCH_RULE: string;
145
+ VALIDATION_FAILED: string;
134
146
  };
135
147
  };
136
148
  export default logs;
@@ -35,4 +35,4 @@ export declare const EnvOptions: {
35
35
  };
36
36
  export declare const printLog: (message: string, messageType: MessageType, logLevel: LogLevel) => void;
37
37
  export declare const parameterizedString: (...args: any[]) => any;
38
- export declare const getElementName: (name: string) => string;
38
+ export declare const getElementName: (name?: string) => string;
@@ -9,4 +9,6 @@ export declare const validateDetokenizeInput: (detokenizeInput: IDetokenizeInput
9
9
  export declare const validateGetByIdInput: (getByIdInput: IGetByIdInput) => void;
10
10
  export declare const validateRevealElementRecords: (records: IRevealElementInput[]) => void;
11
11
  export declare const isValidURL: (url: string) => boolean;
12
+ export declare const isValidRegExp: (input: any) => boolean;
12
13
  export declare const validateConnectionConfig: (config: IConnectionConfig) => void;
14
+ export declare const validateCardNumberLengthCheck: (cardNumber: string) => boolean;