skyflow-js 1.4.0 → 1.8.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.4.0",
5
+ "version": "1.8.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,14 +1,14 @@
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, IGatewayConfig, 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"
8
8
  }
9
9
  export interface ISkyflow {
10
- vaultID: string;
11
- vaultURL: string;
10
+ vaultID?: string;
11
+ vaultURL?: string;
12
12
  getBearerToken: () => Promise<string>;
13
13
  options?: Record<string, any>;
14
14
  }
@@ -16,11 +16,11 @@ 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>;
23
- invokeGateway(config: IGatewayConfig): Promise<unknown>;
23
+ invokeConnection(config: IConnectionConfig): Promise<unknown>;
24
24
  static get ContainerType(): typeof ContainerType;
25
25
  static get ElementType(): typeof ElementType;
26
26
  static get RedactionType(): typeof RedactionType;
@@ -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;
@@ -7,7 +7,7 @@ export declare const PUREJS_TYPES: {
7
7
  INSERT: string;
8
8
  DETOKENIZE: string;
9
9
  GET_BY_SKYFLOWID: string;
10
- INVOKE_GATEWAY: string;
10
+ INVOKE_CONNECTION: string;
11
11
  };
12
12
  export declare const ELEMENT_EVENTS_TO_CLIENT: {
13
13
  CHANGE: string;
@@ -38,6 +38,13 @@ export declare const ELEMENT_EVENTS_TO_IFRAME: {
38
38
  GET_BEARER_TOKEN: string;
39
39
  GET_COLLECT_ELEMENT: string;
40
40
  GET_REVEAL_ELEMENT: string;
41
+ COLLECT_ELEMENT_SET_ERROR: string;
42
+ REVEAL_ELEMENT_SET_ERROR: string;
43
+ REVEAL_ELEMENT_UPDATE_OPTIONS: string;
44
+ };
45
+ export declare const REVEAL_ELEMENT_OPTIONS_TYPES: {
46
+ TOKEN: string;
47
+ ALT_TEXT: string;
41
48
  };
42
49
  export declare const ELEMENT_EVENTS_TO_CONTAINER: {
43
50
  ELEMENT_MOUNTED: string;
@@ -47,8 +54,54 @@ export declare enum ElementType {
47
54
  CVV = "CVV",
48
55
  EXPIRATION_DATE = "EXPIRATION_DATE",
49
56
  CARD_NUMBER = "CARD_NUMBER",
50
- CARDHOLDER_NAME = "CARDHOLDER_NAME"
57
+ CARDHOLDER_NAME = "CARDHOLDER_NAME",
58
+ INPUT_FIELD = "INPUT_FIELD",
59
+ PIN = "PIN"
51
60
  }
61
+ export declare enum CardType {
62
+ VISA = "VISA",
63
+ MASTERCARD = "MASTERCARD",
64
+ AMEX = "AMEX",
65
+ DINERS_CLUB = "DINERS_CLUB",
66
+ DISCOVER = "DISCOVER",
67
+ JCB = "JCB",
68
+ MAESTRO = "MAESTRO",
69
+ UNIONPAY = "UNIONPAY",
70
+ HIPERCARD = "HIPERCARD",
71
+ DEFAULT = "DEFAULT"
72
+ }
73
+ export declare const CARD_NUMBER_MASK: {
74
+ AMEX: (string | {
75
+ X: string;
76
+ })[];
77
+ VISA: (string | {
78
+ X: string;
79
+ })[];
80
+ MASTERCARD: (string | {
81
+ X: string;
82
+ })[];
83
+ DISCOVER: (string | {
84
+ X: string;
85
+ })[];
86
+ DINERS_CLUB: (string | {
87
+ X: string;
88
+ })[];
89
+ JCB: (string | {
90
+ X: string;
91
+ })[];
92
+ MAESTRO: (string | {
93
+ X: string;
94
+ })[];
95
+ UNIONPAY: (string | {
96
+ X: string;
97
+ })[];
98
+ HIPERCARD: (string | {
99
+ X: string;
100
+ })[];
101
+ DEFAULT: (string | {
102
+ X: string;
103
+ })[];
104
+ };
52
105
  export declare const ELEMENTS: {
53
106
  text: {
54
107
  name: string;
@@ -214,6 +267,9 @@ export declare const ELEMENTS: {
214
267
  type: string;
215
268
  };
216
269
  sensitive: boolean;
270
+ mask: (string | {
271
+ X: string;
272
+ })[];
217
273
  regex: RegExp;
218
274
  };
219
275
  EXPIRATION_DATE: {
@@ -222,7 +278,6 @@ export declare const ELEMENTS: {
222
278
  type: string;
223
279
  };
224
280
  sensitive: boolean;
225
- regex: RegExp;
226
281
  };
227
282
  CVV: {
228
283
  name: string;
@@ -233,6 +288,23 @@ export declare const ELEMENTS: {
233
288
  sensitive: boolean;
234
289
  regex: RegExp;
235
290
  };
291
+ INPUT_FIELD: {
292
+ name: string;
293
+ sensitive: boolean;
294
+ attributes: {
295
+ type: string;
296
+ };
297
+ };
298
+ PIN: {
299
+ name: string;
300
+ attributes: {
301
+ type: string;
302
+ maxLength: number;
303
+ minLength: number;
304
+ };
305
+ sensitive: boolean;
306
+ regex: RegExp;
307
+ };
236
308
  };
237
309
  export declare const IFRAME_DEFAULT_STYLES: {
238
310
  height: string;
@@ -267,6 +339,11 @@ export declare const INPUT_WITH_ICON_STYLES: {
267
339
  'background-repeat': string;
268
340
  'text-indent': string;
269
341
  };
342
+ export declare const INPUT_WITH_ICON_DEFAULT_STYLES: {
343
+ 'background-repeat': string;
344
+ 'text-indent': string;
345
+ padding: string;
346
+ };
270
347
  export declare const ERROR_TEXT_STYLES: {
271
348
  color: string;
272
349
  padding: string;
@@ -311,57 +388,55 @@ export declare const COLLECT_ELEMENT_LABEL_DEFAULT_STYLES: {
311
388
  marginBottom: string;
312
389
  };
313
390
  };
314
- export declare const gatewayConfigParseKeys: string[];
315
- export declare enum CardType {
316
- VISA = "VISA",
317
- MASTERCARD = "MASTERCARD",
318
- AMEX = "AMEX",
319
- DINERS_CLUB = "DINERS_CLUB",
320
- DISCOVER = "DISCOVER",
321
- JCB = "JCB",
322
- MAESTRO = "MAESTRO",
323
- UNIONPAY = "UNIONPAY",
324
- HIPERCARD = "HIPERCARD",
325
- DEFAULT = "DEFAULT"
326
- }
391
+ export declare const connectionConfigParseKeys: string[];
327
392
  export declare const CARD_TYPE_REGEX: {
328
393
  VISA: {
329
394
  regex: RegExp;
330
395
  maxCardLength: number;
396
+ cardLengthRange: number[];
331
397
  };
332
398
  MASTERCARD: {
333
399
  regex: RegExp;
334
400
  maxCardLength: number;
401
+ cardLengthRange: number[];
335
402
  };
336
403
  AMEX: {
337
404
  regex: RegExp;
338
405
  maxCardLength: number;
406
+ cardLengthRange: number[];
339
407
  };
340
408
  DINERS_CLUB: {
341
409
  regex: RegExp;
342
410
  maxCardLength: number;
411
+ cardLengthRange: number[];
343
412
  };
344
413
  DISCOVER: {
345
414
  regex: RegExp;
346
415
  maxCardLength: number;
416
+ cardLengthRange: number[];
347
417
  };
348
418
  JCB: {
349
419
  regex: RegExp;
350
420
  maxCardLength: number;
421
+ cardLengthRange: number[];
351
422
  };
352
423
  HIPERCARD: {
353
424
  regex: RegExp;
354
425
  maxCardLength: number;
426
+ cardLengthRange: number[];
355
427
  };
356
428
  UNIONPAY: {
357
429
  regex: RegExp;
358
430
  maxCardLength: number;
431
+ cardLengthRange: number[];
359
432
  };
360
433
  MAESTRO: {
361
434
  regex: RegExp;
362
435
  maxCardLength: number;
436
+ cardLengthRange: number[];
363
437
  };
364
438
  };
439
+ export declare const DEFAULT_CARD_LENGTH_RANGE: number[];
365
440
  export declare const CARD_ENCODED_ICONS: {
366
441
  DEFAULT: string;
367
442
  AMEX: string;
@@ -374,3 +449,23 @@ export declare const CARD_ENCODED_ICONS: {
374
449
  UNIONPAY: string;
375
450
  VISA: string;
376
451
  };
452
+ export declare const EXPIRY_DATE_MASK: {
453
+ 'MM/YYYY': (string | {
454
+ X: string;
455
+ Y: string;
456
+ })[];
457
+ 'MM/YY': (string | {
458
+ X: string;
459
+ Y: string;
460
+ })[];
461
+ 'YYYY/MM': (string | {
462
+ X: string;
463
+ Y: string;
464
+ })[];
465
+ 'YY/MM': (string | {
466
+ X: string;
467
+ Y: string;
468
+ })[];
469
+ };
470
+ export declare const DEFAULT_EXPIRATION_DATE_FORMAT = "MM/YY";
471
+ export declare const ALLOWED_EXPIRY_DATE_FORMATS: 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,10 +1,10 @@
1
- import { IDetokenizeInput, IGetByIdInput, IGatewayConfig } from '../../utils/common';
1
+ import { IDetokenizeInput, IGetByIdInput, IConnectionConfig } from '../../utils/common';
2
2
  declare class PureJsController {
3
3
  #private;
4
4
  constructor(client: any, context: any);
5
5
  detokenize(detokenizeInput: IDetokenizeInput): Promise<any>;
6
6
  insert(records: any, options: any): Promise<any>;
7
7
  getById(getByIdInput: IGetByIdInput): Promise<unknown>;
8
- invokeGateway(config: IGatewayConfig): Promise<unknown>;
8
+ invokeConnection(config: IConnectionConfig): Promise<unknown>;
9
9
  }
10
10
  export default PureJsController;
@@ -3,7 +3,7 @@ export default class IFrame {
3
3
  metadata: any;
4
4
  iframe: HTMLIFrameElement;
5
5
  container?: Element;
6
- constructor(name: any, metadata: any, containerId: any);
6
+ constructor(name: any, metadata: any, containerId: any, logLevel: any);
7
7
  mount: (domElement: any) => void;
8
8
  unmount: () => void;
9
9
  }
@@ -19,5 +19,9 @@ declare class Element {
19
19
  iframeName(): string;
20
20
  isMounted(): boolean;
21
21
  isValidElement(): boolean;
22
+ setError(clientErrorText: string): void;
23
+ resetError(): void;
24
+ setValue(elementValue: string): void;
25
+ clearValue(): void;
22
26
  }
23
27
  export default Element;
@@ -7,5 +7,13 @@ declare class RevealElement {
7
7
  iframeName(): string;
8
8
  isMounted(): boolean;
9
9
  hasToken(): boolean;
10
+ isClientSetError(): boolean;
11
+ getRecordData(): any;
12
+ setError(clientErrorText: string): void;
13
+ resetError(): void;
14
+ setAltText(altText: string): void;
15
+ clearAltText(): void;
16
+ setToken(token: string): void;
17
+ unmount(): void;
10
18
  }
11
19
  export default RevealElement;
@@ -1,9 +1,10 @@
1
+ import { LogLevel } from '../../utils/common';
1
2
  export default class FrameElements {
2
3
  #private;
3
4
  private static group?;
4
5
  private static frameElements?;
5
6
  private getOrCreateIFrameFormElement;
6
- constructor(getOrCreateIFrameFormElement: any, metaData: any);
7
+ constructor(getOrCreateIFrameFormElement: any, metaData: any, logLevel: LogLevel);
7
8
  static start: () => void;
8
9
  static init: (getOrCreateIFrameFormElement: Function, metaData: any) => void;
9
10
  setup: () => void;
@@ -1,5 +1,5 @@
1
1
  import EventEmitter from '../../../event-emitter';
2
- import { Context } 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,22 @@ 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
+ doesClientHasError: boolean;
26
+ clientErrorText: string | undefined;
27
+ expirationDateFormat: string;
28
+ constructor(name: string, label: string, metaData: any, context: Context);
23
29
  onFocusChange: (focus: boolean) => void;
24
30
  changeFocus: (focus: boolean) => void;
25
31
  setReplacePattern(pattern: string[]): void;
26
32
  setMask(mask: string[]): void;
27
- setValidation(): void;
33
+ setValidation(validations: IValidationRule[] | undefined): void;
34
+ setExpirationDateFormat(format: string): void;
28
35
  setSensitive(sensitive?: boolean): void;
29
36
  setValue: (value?: string, valid?: boolean) => void;
30
37
  getValue: () => string | undefined;
@@ -37,6 +44,7 @@ export declare class IFrameFormElement extends EventEmitter {
37
44
  value: string | undefined;
38
45
  };
39
46
  validator(value: string): boolean;
47
+ validateCustomValidations(value: string): boolean;
40
48
  collectBusEvents: () => void;
41
49
  sendChangeStatus: (inputEvent?: boolean) => void;
42
50
  resetData(): void;
@@ -50,7 +58,8 @@ export declare class IFrameForm {
50
58
  private controllerId;
51
59
  private clientDomain;
52
60
  private context;
53
- constructor(controllerId: string, clientDomain: string);
61
+ private logLevel;
62
+ constructor(controllerId: string, clientDomain: string, logLevel: LogLevel);
54
63
  setClient(client: any): void;
55
64
  setClientMetadata(clientMetaData: any): void;
56
65
  setContext(context: Context): void;
@@ -1,12 +1,14 @@
1
1
  import 'jquery-mask-plugin/dist/jquery.mask.min';
2
2
  import { IFrameFormElement } from './iFrameForm';
3
+ import { LogLevel } from '../../utils/common';
3
4
  export declare class FrameController {
4
5
  #private;
5
6
  controller?: FrameController;
6
7
  controllerId: string;
7
8
  private clientDomain;
8
- constructor(controllerId: string);
9
- static init(uuid: string): FrameController;
9
+ private CLASS_NAME;
10
+ constructor(controllerId: string, logLevel: LogLevel);
11
+ static init(uuid: string, logLevel: any): FrameController;
10
12
  }
11
13
  export declare class FrameElement {
12
14
  options: any;
@@ -33,4 +35,5 @@ export declare class FrameElement {
33
35
  }): void;
34
36
  setClass(types: string[], dom?: HTMLElement, preText?: string): void;
35
37
  updateOptions(options: any): void;
38
+ private applyMask;
36
39
  }
@@ -1,9 +1,9 @@
1
- import { IGatewayConfig } from '../../../utils/common';
1
+ import { IConnectionConfig } from '../../../utils/common';
2
2
  declare class PureJsFrameController {
3
3
  #private;
4
4
  constructor();
5
5
  static init(): PureJsFrameController;
6
6
  insertData(records: any, options: any): Promise<unknown>;
7
- sendInvokeGateWayRequest(config: IGatewayConfig): Promise<unknown>;
7
+ sendInvokeConnectionRequest(config: IConnectionConfig): Promise<unknown>;
8
8
  }
9
9
  export default PureJsFrameController;
@@ -3,5 +3,8 @@ declare class RevealFrame {
3
3
  static revealFrame: RevealFrame;
4
4
  static init(): void;
5
5
  constructor(record: any, context: any);
6
+ private setRevealError;
7
+ private updateRevealElementOptions;
8
+ private updateDataView;
6
9
  }
7
10
  export default RevealFrame;
@@ -1,4 +1,4 @@
1
- import { IInsertRecordInput, IInsertRecord } from '../utils/common';
1
+ import { IInsertRecordInput, IInsertRecord, IValidationRule } from '../utils/common';
2
2
  export declare const constructInsertRecordRequest: (records: IInsertRecordInput, options?: Record<string, any>) => any;
3
3
  export declare const constructInsertRecordResponse: (responseBody: any, tokens: boolean, records: IInsertRecord[]) => {
4
4
  records: any;
@@ -6,3 +6,4 @@ export declare const constructInsertRecordResponse: (responseBody: any, tokens:
6
6
  export declare const constructElementsInsertReq: (req: any, options: any) => {
7
7
  records: IInsertRecord[];
8
8
  };
9
+ export declare const checkForElementMatchRule: (validations: IValidationRule[]) => boolean;
@@ -1,4 +1,8 @@
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;
8
+ export declare const formatOptions: (elementType: any, options: any, logLevel: any) => any;
@@ -1,2 +1,2 @@
1
- export declare function gatewayConfigParser(data: any, configKey: any): void;
2
- export declare function constructInvokeGatewayRequest(data: any): Promise<any>;
1
+ export declare function connectionConfigParser(data: any, configKey: any): void;
2
+ export declare function constructInvokeConnectionRequest(data: any): Promise<any>;
@@ -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
  }
@@ -62,8 +67,8 @@ export interface Context {
62
67
  logLevel: LogLevel;
63
68
  env: Env;
64
69
  }
65
- export interface IGatewayConfig {
66
- gatewayURL: string;
70
+ export interface IConnectionConfig {
71
+ connectionURL: string;
67
72
  methodName: RequestMethod;
68
73
  pathParams?: any;
69
74
  queryParams?: any;
@@ -71,3 +76,7 @@ export interface IGatewayConfig {
71
76
  requestHeader?: any;
72
77
  responseBody?: any;
73
78
  }
79
+ export interface IValidationRule {
80
+ type: ValidationRuleType;
81
+ params: any;
82
+ }