@evervault/react-native 2.3.0 → 2.5.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.
@@ -1,5 +1,12 @@
1
1
  import { BaseEvervaultInputProps, EvervaultInput } from "../Input";
2
- export type CardCvcProps = BaseEvervaultInputProps;
2
+ export interface CardCvcProps extends BaseEvervaultInputProps {
3
+ /**
4
+ * Whether to obfuscate the entire CVC value.
5
+ *
6
+ * If a string is provided, it will be used to obfuscate the value.
7
+ */
8
+ obfuscateValue?: boolean | string;
9
+ }
3
10
  export type CardCvc = EvervaultInput;
4
- export declare const CardCvc: import("react").ForwardRefExoticComponent<BaseEvervaultInputProps & import("react").RefAttributes<EvervaultInput>>;
11
+ export declare const CardCvc: import("react").ForwardRefExoticComponent<CardCvcProps & import("react").RefAttributes<EvervaultInput>>;
5
12
  //# sourceMappingURL=Cvc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Cvc.d.ts","sourceRoot":"","sources":["../../src/Card/Cvc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAQ,MAAM,UAAU,CAAC;AAazE,MAAM,MAAM,YAAY,GAAG,uBAAuB,CAAC;AAEnD,MAAM,MAAM,OAAO,GAAG,cAAc,CAAC;AAErC,eAAO,MAAM,OAAO,oHAgClB,CAAC"}
1
+ {"version":3,"file":"Cvc.d.ts","sourceRoot":"","sources":["../../src/Card/Cvc.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAQ,MAAM,UAAU,CAAC;AAazE,MAAM,WAAW,YAAa,SAAQ,uBAAuB;IAC3D;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,OAAO,GAAG,cAAc,CAAC;AAErC,eAAO,MAAM,OAAO,yGAgClB,CAAC"}
@@ -1,5 +1,12 @@
1
1
  import { BaseEvervaultInputProps, EvervaultInput } from "../Input";
2
- export type CardNumberProps = BaseEvervaultInputProps;
2
+ export interface CardNumberProps extends BaseEvervaultInputProps {
3
+ /**
4
+ * Whether to obfuscate the card number value (excluding the last 4 digits).
5
+ *
6
+ * If a string is provided, it will be used to obfuscate the value.
7
+ */
8
+ obfuscateValue?: boolean | string;
9
+ }
3
10
  export type CardNumber = EvervaultInput;
4
- export declare const CardNumber: import("react").ForwardRefExoticComponent<BaseEvervaultInputProps & import("react").RefAttributes<EvervaultInput>>;
11
+ export declare const CardNumber: import("react").ForwardRefExoticComponent<CardNumberProps & import("react").RefAttributes<EvervaultInput>>;
5
12
  //# sourceMappingURL=Number.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../src/Card/Number.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAQ,MAAM,UAAU,CAAC;AAazE,MAAM,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,eAAO,MAAM,UAAU,oHA4BtB,CAAC"}
1
+ {"version":3,"file":"Number.d.ts","sourceRoot":"","sources":["../../src/Card/Number.tsx"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAQ,MAAM,UAAU,CAAC;AAazE,MAAM,WAAW,eAAgB,SAAQ,uBAAuB;IAC9D;;;;OAIG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,MAAM,UAAU,GAAG,cAAc,CAAC;AAExC,eAAO,MAAM,UAAU,4GA4BtB,CAAC"}
@@ -8,8 +8,8 @@ export type Card = CardRef;
8
8
  export declare const Card: import("react").ForwardRefExoticComponent<import("./Root").CardProps & import("react").RefAttributes<CardRoot>> & {
9
9
  Holder: import("react").ForwardRefExoticComponent<import("..").EvervaultInputProps & import("react").RefAttributes<import("..").EvervaultInput>>;
10
10
  Expiry: import("react").ForwardRefExoticComponent<import("..").EvervaultInputProps & import("react").RefAttributes<import("..").EvervaultInput>>;
11
- Cvc: import("react").ForwardRefExoticComponent<import("..").EvervaultInputProps & import("react").RefAttributes<import("..").EvervaultInput>>;
12
- Number: import("react").ForwardRefExoticComponent<import("..").EvervaultInputProps & import("react").RefAttributes<import("..").EvervaultInput>>;
11
+ Cvc: import("react").ForwardRefExoticComponent<import("./Cvc").CardCvcProps & import("react").RefAttributes<import("..").EvervaultInput>>;
12
+ Number: import("react").ForwardRefExoticComponent<import("./Number").CardNumberProps & import("react").RefAttributes<import("..").EvervaultInput>>;
13
13
  };
14
14
  export type { CardHolderProps } from "./Holder";
15
15
  export { CardHolder };
package/build/Input.d.ts CHANGED
@@ -11,6 +11,7 @@ export declare function mask(format: string): MaskArray;
11
11
  export interface EvervaultInputProps<Values extends Record<string, unknown>> extends BaseEvervaultInputProps {
12
12
  name: keyof Values;
13
13
  mask?: Mask;
14
+ obfuscateValue?: boolean | string;
14
15
  }
15
16
  export declare const EvervaultInput: <Values extends Record<string, unknown>>(props: EvervaultInputProps<Values> & {
16
17
  ref?: Ref<EvervaultInput>;
@@ -1 +1 @@
1
- {"version":3,"file":"Input.d.ts","sourceRoot":"","sources":["../src/Input.tsx"],"names":[],"mappings":"AAAA,OAAO,EAIL,SAAS,EACT,GAAG,EAMJ,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAGzD,OAAkB,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAErE,MAAM,WAAW,0BAA0B;IACzC,cAAc,EAAE,UAAU,GAAG,QAAQ,GAAG,WAAW,GAAG,KAAK,CAAC;CAC7D;AAED,eAAO,MAAM,qBAAqB,qDAEhC,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,IAAI,CAC/B,SAAS,EACP,WAAW,GACX,OAAO,GACP,MAAM,GACN,OAAO,GACP,SAAS,GACT,iBAAiB,GACjB,eAAe,CA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,wBAAgB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAqB9C;AAED,MAAM,WAAW,mBAAmB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACzE,SAAQ,uBAAuB;IAC/B,IAAI,EAAE,MAAM,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,cAAc,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;CACnC;AAED,eAAO,MAAM,cAAc,EAgErB,CAAC,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC3C,KAAK,EAAE,mBAAmB,CAAC,MAAM,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAA;CAAE,KAC/D,SAAS,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { ThreeDSecureSession } from "./types";
2
+ export type ThreeDSecureEventType = "requestChallenge";
3
+ export declare class ThreeDSecureEvent {
4
+ readonly type: ThreeDSecureEventType;
5
+ readonly session: ThreeDSecureSession;
6
+ private _defaultPrevented;
7
+ constructor(type: ThreeDSecureEventType, session: ThreeDSecureSession, _defaultPrevented?: boolean);
8
+ preventDefault(): void;
9
+ get defaultPrevented(): boolean;
10
+ }
11
+ //# sourceMappingURL=event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event.d.ts","sourceRoot":"","sources":["../../src/ThreeDSecure/event.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAEvD,qBAAa,iBAAiB;aAEV,IAAI,EAAE,qBAAqB;aAC3B,OAAO,EAAE,mBAAmB;IAC5C,OAAO,CAAC,iBAAiB;gBAFT,IAAI,EAAE,qBAAqB,EAC3B,OAAO,EAAE,mBAAmB,EACpC,iBAAiB,GAAE,OAAe;IAGrC,cAAc;IAIrB,IAAW,gBAAgB,YAE1B;CACF"}
@@ -1,6 +1,6 @@
1
- import { ThreeDSecureCallbacks, ThreeDSecureSessionsParams, ThreeDSecureSession } from "./types";
1
+ import { ThreeDSecureSessionsParams, ThreeDSecureSession, ThreeDSecureOptions } from "./types";
2
2
  export declare function stopPolling(intervalRef: React.MutableRefObject<NodeJS.Timeout | null>, setIsVisible: (show: boolean) => void): void;
3
- export declare function startSession(session: ThreeDSecureSession, callbacks: ThreeDSecureCallbacks | undefined, intervalRef: React.MutableRefObject<NodeJS.Timeout | null>, setIsVisible: (show: boolean) => void): Promise<void>;
4
- export declare function pollSession(session: ThreeDSecureSession, callbacks: ThreeDSecureCallbacks | undefined, intervalRef: React.MutableRefObject<NodeJS.Timeout | null>, setIsVisible: (show: boolean) => void, interval?: number): void;
5
- export declare function threeDSecureSession({ sessionId, appId, callbacks, intervalRef, setIsVisible, }: ThreeDSecureSessionsParams): ThreeDSecureSession;
3
+ export declare function startSession(session: ThreeDSecureSession, options: ThreeDSecureOptions | undefined, intervalRef: React.MutableRefObject<NodeJS.Timeout | null>, setIsVisible: (show: boolean) => void): Promise<void>;
4
+ export declare function pollSession(session: ThreeDSecureSession, options: ThreeDSecureOptions | undefined, intervalRef: React.MutableRefObject<NodeJS.Timeout | null>, setIsVisible: (show: boolean) => void, interval?: number): void;
5
+ export declare function threeDSecureSession({ sessionId, appId, options, intervalRef, setIsVisible, }: ThreeDSecureSessionsParams): ThreeDSecureSession;
6
6
  //# sourceMappingURL=session.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/ThreeDSecure/session.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,qBAAqB,EACrB,0BAA0B,EAC1B,mBAAmB,EAEpB,MAAM,SAAS,CAAC;AAGjB,wBAAgB,WAAW,CACzB,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,EAC1D,YAAY,EAAE,CAAC,IAAI,EAAE,OA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,EAC5B,OAAO,EAAE,mBAAmB,GAAG,SAAS,EACxC,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,EAC1D,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,EACrC,QAAQ,SAAO,QAgDhB;AAED,wBAAgB,mBAAmB,CAAC,EAClC,SAAS,EACT,KAAK,EACL,OAAO,EACP,WAAW,EACX,YAAY,GACb,EAAE,0BAA0B,GAAG,mBAAmB,CA+ClD"}
@@ -1,8 +1,14 @@
1
+ import { ThreeDSecureEvent } from "./event";
1
2
  export interface ThreeDSecureCallbacks {
2
3
  /**
3
4
  * The error event will be fired if the component fails to load.
4
5
  */
5
6
  onError?(error: Error): void;
7
+ /**
8
+ * The 'requestChallenge' event will be fired if the 3DS authentication process requires a challenge.
9
+ * If you'd like to fail the authentication, you should call `preventDefault` on the passed event.
10
+ */
11
+ onRequestChallenge?(event: ThreeDSecureEvent): void;
6
12
  /**
7
13
  * The 'failure' event will be fired if the 3DS authentication process fails. You should use this event to handle the failure and inform the user and prompt them to try again.
8
14
  * If the user cancels the 3DS authentication process this event will be fired.
@@ -15,6 +21,12 @@ export interface ThreeDSecureCallbacks {
15
21
  */
16
22
  onSuccess?(): void;
17
23
  }
24
+ export interface ThreeDSecureOptions extends ThreeDSecureCallbacks {
25
+ /**
26
+ * If set to `true` (or a function that returns `true`), the authentication will fail if a challenge is required.
27
+ */
28
+ failOnChallenge?: boolean | (() => Promise<boolean>);
29
+ }
18
30
  export interface ThreeDSecureInitialState {
19
31
  session: ThreeDSecureSession | null;
20
32
  isVisible: boolean;
@@ -35,7 +47,7 @@ export interface ThreeDSecureSessionResponse {
35
47
  }
36
48
  export interface ThreeDSecureSessionsParams {
37
49
  appId: string;
38
- callbacks?: ThreeDSecureCallbacks;
50
+ options?: ThreeDSecureOptions;
39
51
  intervalRef: React.MutableRefObject<NodeJS.Timeout | null>;
40
52
  sessionId: string;
41
53
  setIsVisible: (show: boolean) => void;
@@ -50,8 +62,8 @@ export interface ThreeDSecureState extends ThreeDSecureInitialState {
50
62
  * The `start()` function is used to kick off the 3DS authentication process.
51
63
  *
52
64
  * @param sessionId The 3DS session ID. A 3DS session can be created using the [Evervault API](https://docs.evervault.com/api-reference#createThreeDSSession).
53
- * @param callbacks The callbacks to be called when the 3DS authentication process is finished.
65
+ * @param options The options to be used for the 3DS authentication process.
54
66
  */
55
- start(sessionId: string, callbacks?: ThreeDSecureCallbacks): void;
67
+ start(sessionId: string, options?: ThreeDSecureOptions): void;
56
68
  }
57
69
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ThreeDSecure/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAE7B;;;OAGG;IACH,SAAS,CAAC,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAE/B;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACpC,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACxB,GAAG,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE,aAAa,CAAC;C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CAAC,IAAI,CAAC,CAAC;IACxB,GAAG,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAAC;IAC5C,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,MAAM,aAAa,GAAG,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAAC;AAEtE,MAAM,WAAW,2BAA2B;IAC1C,UAAU,EAAE;QACV,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;KACd,CAAC;IACF,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,WAAW,EAAE,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;IAC3D,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,iBAAkB,SAAQ,wBAAwB;IACjE;;;OAGG;IACH,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAExB;;;;;OAKG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,IAAI,CAAC;CAC/D"}
@@ -1,3 +1,6 @@
1
1
  import { ThreeDSecureState } from "./types";
2
- export declare function useThreeDSecure(): ThreeDSecureState;
2
+ export interface UseThreeDSecureOptions {
3
+ failOnChallenge?: boolean | (() => Promise<boolean>);
4
+ }
5
+ export declare function useThreeDSecure(options?: UseThreeDSecureOptions): ThreeDSecureState;
3
6
  //# sourceMappingURL=useThreeDSecure.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useThreeDSecure.d.ts","sourceRoot":"","sources":["../../src/ThreeDSecure/useThreeDSecure.ts"],"names":[],"mappings":"AAGA,OAAO,EAAuB,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAGjE,wBAAgB,eAAe,IAAI,iBAAiB,CAwCnD"}
1
+ {"version":3,"file":"useThreeDSecure.d.ts","sourceRoot":"","sources":["../../src/ThreeDSecure/useThreeDSecure.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAGjB,MAAM,WAAW,sBAAsB;IACrC,eAAe,CAAC,EAAE,OAAO,GAAG,CAAC,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC;CACtD;AAED,wBAAgB,eAAe,CAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,iBAAiB,CA+CnB"}
@@ -608,50 +608,6 @@ function useController(props) {
608
608
  }), [field, formState, fieldState]);
609
609
  }
610
610
 
611
- /**
612
- * Component based on `useController` hook to work with controlled component.
613
- *
614
- * @remarks
615
- * [API](https://react-hook-form.com/docs/usecontroller/controller) • [Demo](https://codesandbox.io/s/react-hook-form-v6-controller-ts-jwyzw) • [Video](https://www.youtube.com/watch?v=N2UNk_UCVyA)
616
- *
617
- * @param props - the path name to the form field value, and validation rules.
618
- *
619
- * @returns provide field handler functions, field and form state.
620
- *
621
- * @example
622
- * ```tsx
623
- * function App() {
624
- * const { control } = useForm<FormValues>({
625
- * defaultValues: {
626
- * test: ""
627
- * }
628
- * });
629
- *
630
- * return (
631
- * <form>
632
- * <Controller
633
- * control={control}
634
- * name="test"
635
- * render={({ field: { onChange, onBlur, value, ref }, formState, fieldState }) => (
636
- * <>
637
- * <input
638
- * onChange={onChange} // send value to hook form
639
- * onBlur={onBlur} // notify when input is touched
640
- * value={value} // return updated value
641
- * ref={ref} // set ref for focus management
642
- * />
643
- * <p>{formState.isSubmitted ? "submitted" : ""}</p>
644
- * <p>{fieldState.isTouched ? "touched" : ""}</p>
645
- * </>
646
- * )}
647
- * />
648
- * </form>
649
- * );
650
- * }
651
- * ```
652
- */
653
- const Controller = (props) => props.render(useController(props));
654
-
655
611
  var appendErrors = (name, validateAllFieldCriteria, errors, type, message) => validateAllFieldCriteria
656
612
  ? {
657
613
  ...errors[name],
@@ -7428,44 +7384,69 @@ function useForwardedInputRef(ref) {
7428
7384
  return inputRef;
7429
7385
  }
7430
7386
  function mask(format) {
7431
- return format.split("").map((char) => {
7387
+ const maskArray = [];
7388
+ let isObfuscated = false;
7389
+ format.split("").forEach((char) => {
7390
+ if (char === "[") {
7391
+ isObfuscated = true;
7392
+ return;
7393
+ }
7394
+ else if (char === "]") {
7395
+ isObfuscated = false;
7396
+ return;
7397
+ }
7398
+ let value = char;
7432
7399
  if (char === "9") {
7433
- return /\d/;
7400
+ value = isObfuscated ? [/\d/] : /\d/;
7434
7401
  }
7435
- return char;
7402
+ maskArray.push(value);
7436
7403
  });
7404
+ return maskArray;
7437
7405
  }
7438
- const EvervaultInput = React.forwardRef(function EvervaultInput({ name, mask, ...props }, ref) {
7406
+ const EvervaultInput = React.forwardRef(function EvervaultInput({ name, mask, obfuscateValue, ...props }, ref) {
7439
7407
  const { validationMode } = React.useContext(EvervaultInputContext);
7440
7408
  const inputRef = useForwardedInputRef(ref);
7441
7409
  const methods = useFormContext();
7442
- return (jsxRuntime.jsx(Controller, { control: methods.control, name: name, shouldUnregister: true, render: ({ field, fieldState }) => (jsxRuntime.jsx(MaskInput
7410
+ const { field, fieldState } = useController({
7411
+ control: methods.control,
7412
+ name,
7413
+ shouldUnregister: true,
7414
+ });
7415
+ const obfuscationCharacter = React.useMemo(() => {
7416
+ if (typeof obfuscateValue === "string") {
7417
+ return obfuscateValue;
7418
+ }
7419
+ else {
7420
+ return "•";
7421
+ }
7422
+ }, [obfuscateValue]);
7423
+ return (jsxRuntime.jsx(MaskInput
7424
+ // Overridable props
7425
+ , {
7443
7426
  // Overridable props
7444
- , {
7445
- // Overridable props
7446
- id: field.name, ...props,
7447
- // Strict props
7448
- ref: mergeRefs(inputRef, field.ref), editable: !field.disabled && (props.editable ?? true), onBlur: (evt) => {
7449
- const shouldValidate = validationMode === "onBlur" ||
7450
- validationMode === "onTouched" ||
7451
- validationMode === "all";
7452
- methods.setValue(field.name, field.value, {
7453
- shouldDirty: true,
7454
- shouldTouch: true,
7455
- shouldValidate,
7456
- });
7457
- props.onBlur?.(evt);
7458
- }, mask: mask, maskAutoComplete: !!mask, value: field.value, onChangeText: (masked, unmasked) => {
7459
- const shouldValidate = (validationMode === "onTouched" && fieldState.isTouched) ||
7460
- ((validationMode === "onChange" || validationMode === "all") &&
7461
- (!!fieldState.error || fieldState.isTouched));
7462
- methods.setValue(field.name, unmasked, {
7463
- shouldDirty: true,
7464
- shouldValidate,
7465
- });
7466
- },
7467
- // Remove unwanted props
7468
- defaultValue: undefined, onChange: undefined })) }));
7427
+ id: field.name, ...props,
7428
+ // Strict props
7429
+ ref: mergeRefs(inputRef, field.ref), editable: !field.disabled && (props.editable ?? true), onBlur: (evt) => {
7430
+ const shouldValidate = validationMode === "onBlur" ||
7431
+ validationMode === "onTouched" ||
7432
+ validationMode === "all";
7433
+ methods.setValue(field.name, field.value, {
7434
+ shouldDirty: true,
7435
+ shouldTouch: true,
7436
+ shouldValidate,
7437
+ });
7438
+ props.onBlur?.(evt);
7439
+ }, mask: mask, maskAutoComplete: !!mask, obfuscationCharacter: obfuscationCharacter, showObfuscatedValue: !!obfuscateValue, value: field.value, onChangeText: (masked, unmasked) => {
7440
+ const shouldValidate = (validationMode === "onTouched" && fieldState.isTouched) ||
7441
+ ((validationMode === "onChange" || validationMode === "all") &&
7442
+ (!!fieldState.error || fieldState.isTouched));
7443
+ methods.setValue(field.name, unmasked, {
7444
+ shouldDirty: true,
7445
+ shouldValidate,
7446
+ });
7447
+ },
7448
+ // Remove unwanted props
7449
+ defaultValue: undefined, onChange: undefined }));
7469
7450
  });
7470
7451
 
7471
7452
  const DEFAULT_ACCEPTED_BRANDS = [];
@@ -7538,9 +7519,9 @@ const CardExpiry = React.forwardRef(function CardExpiry(props, ref) {
7538
7519
  return (jsxRuntime.jsx(EvervaultInput, { placeholder: "MM / YY", ...props, ref: ref, name: "expiry", mask: CARD_EXPIRY_MASK, inputMode: "numeric", autoComplete: "cc-exp", keyboardType: "number-pad" }));
7539
7520
  });
7540
7521
 
7541
- const DEFAULT_CARD_CVC_MASK = mask("999");
7522
+ const DEFAULT_CARD_CVC_MASK = mask("[999]");
7542
7523
  const CARD_CVC_MASKS = {
7543
- "american-express": mask("9999"),
7524
+ "american-express": mask("[9999]"),
7544
7525
  };
7545
7526
  const CardCvc = React.forwardRef(function CardCvc(props, ref) {
7546
7527
  const methods = useFormContext();
@@ -7558,10 +7539,10 @@ const CardCvc = React.forwardRef(function CardCvc(props, ref) {
7558
7539
  return (jsxRuntime.jsx(EvervaultInput, { placeholder: "CVC", ...props, ref: ref, name: "cvc", mask: mask, inputMode: "numeric", autoComplete: "cc-csc", keyboardType: "number-pad" }));
7559
7540
  });
7560
7541
 
7561
- const DEFAULT_CARD_NUMBER_MASK = mask("9999 9999 9999 9999");
7542
+ const DEFAULT_CARD_NUMBER_MASK = mask("9999 99[99 9999 9999]");
7562
7543
  const CARD_NUMBER_MASKS = {
7563
- unionpay: mask("9999 9999 9999 9999 999"),
7564
- "american-express": mask("9999 999999 99999"),
7544
+ unionpay: mask("9999 99[99 9999 9999 999]"),
7545
+ "american-express": mask("9999 99[9999 99999]"),
7565
7546
  };
7566
7547
  const CardNumber = React.forwardRef(function CardNumber(props, ref) {
7567
7548
  const mask = React.useCallback((text) => {
@@ -7622,6 +7603,23 @@ const defaultStyles = reactNative.StyleSheet.create({
7622
7603
  },
7623
7604
  });
7624
7605
 
7606
+ class ThreeDSecureEvent {
7607
+ type;
7608
+ session;
7609
+ _defaultPrevented;
7610
+ constructor(type, session, _defaultPrevented = false) {
7611
+ this.type = type;
7612
+ this.session = session;
7613
+ this._defaultPrevented = _defaultPrevented;
7614
+ }
7615
+ preventDefault() {
7616
+ this._defaultPrevented = true;
7617
+ }
7618
+ get defaultPrevented() {
7619
+ return this._defaultPrevented;
7620
+ }
7621
+ }
7622
+
7625
7623
  function stopPolling(intervalRef, setIsVisible) {
7626
7624
  setIsVisible(false);
7627
7625
  if (intervalRef.current) {
@@ -7629,55 +7627,91 @@ function stopPolling(intervalRef, setIsVisible) {
7629
7627
  intervalRef.current = null;
7630
7628
  }
7631
7629
  }
7632
- async function startSession(session, callbacks, intervalRef, setIsVisible) {
7630
+ async function startSession(session, options, intervalRef, setIsVisible) {
7633
7631
  try {
7634
7632
  const sessionState = await session.get();
7633
+ function fail() {
7634
+ stopPolling(intervalRef, setIsVisible);
7635
+ options?.onFailure?.(new Error("3DS session failed"));
7636
+ }
7635
7637
  switch (sessionState.status) {
7636
- case "success":
7638
+ case "success": {
7637
7639
  stopPolling(intervalRef, setIsVisible);
7638
- callbacks?.onSuccess?.();
7640
+ options?.onSuccess?.();
7639
7641
  break;
7640
- case "failure":
7641
- stopPolling(intervalRef, setIsVisible);
7642
- callbacks?.onFailure?.(new Error("3DS session failed"));
7642
+ }
7643
+ case "failure": {
7644
+ fail();
7643
7645
  break;
7644
- case "action-required":
7646
+ }
7647
+ case "action-required": {
7648
+ const failOnChallenge = typeof options?.failOnChallenge === "function"
7649
+ ? await options.failOnChallenge()
7650
+ : options?.failOnChallenge ?? false;
7651
+ if (failOnChallenge) {
7652
+ fail();
7653
+ break;
7654
+ }
7655
+ const event = new ThreeDSecureEvent("requestChallenge", session);
7656
+ options?.onRequestChallenge?.(event);
7657
+ if (event.defaultPrevented) {
7658
+ fail();
7659
+ break;
7660
+ }
7645
7661
  setIsVisible(true);
7646
- pollSession(session, callbacks, intervalRef, setIsVisible);
7647
- break;
7648
- default:
7649
- break;
7662
+ pollSession(session, options, intervalRef, setIsVisible);
7663
+ }
7650
7664
  }
7651
7665
  }
7652
7666
  catch (error) {
7653
7667
  console.error("Error checking session state", error);
7654
- callbacks?.onError?.(new Error("Failed to check 3DS session state"));
7668
+ options?.onError?.(new Error("Failed to check 3DS session state"));
7655
7669
  }
7656
7670
  }
7657
- function pollSession(session, callbacks, intervalRef, setIsVisible, interval = 3000) {
7671
+ function pollSession(session, options, intervalRef, setIsVisible, interval = 3000) {
7672
+ function fail() {
7673
+ stopPolling(intervalRef, setIsVisible);
7674
+ options?.onFailure?.(new Error("3DS session failed"));
7675
+ }
7658
7676
  intervalRef.current = setInterval(async () => {
7659
7677
  try {
7660
7678
  const pollResponse = await session.get();
7661
- if (pollResponse.status === "success") {
7662
- stopPolling(intervalRef, setIsVisible);
7663
- callbacks?.onSuccess?.();
7664
- }
7665
- else if (pollResponse.status === "failure") {
7666
- stopPolling(intervalRef, setIsVisible);
7667
- callbacks?.onFailure?.(new Error("3DS session failed"));
7668
- }
7669
- else {
7670
- setIsVisible(true);
7679
+ switch (pollResponse.status) {
7680
+ case "success": {
7681
+ stopPolling(intervalRef, setIsVisible);
7682
+ options?.onSuccess?.();
7683
+ break;
7684
+ }
7685
+ case "failure": {
7686
+ fail();
7687
+ break;
7688
+ }
7689
+ case "action-required": {
7690
+ const failOnChallenge = typeof options?.failOnChallenge === "function"
7691
+ ? await options.failOnChallenge()
7692
+ : options?.failOnChallenge ?? false;
7693
+ if (failOnChallenge) {
7694
+ fail();
7695
+ break;
7696
+ }
7697
+ const event = new ThreeDSecureEvent("requestChallenge", session);
7698
+ options?.onRequestChallenge?.(event);
7699
+ if (event.defaultPrevented) {
7700
+ fail();
7701
+ break;
7702
+ }
7703
+ setIsVisible(true);
7704
+ }
7671
7705
  }
7672
7706
  }
7673
7707
  catch (error) {
7674
7708
  stopPolling(intervalRef, setIsVisible);
7675
7709
  console.error("Error polling session", error);
7676
- callbacks?.onError?.(new Error("Error polling 3DS session"));
7710
+ options?.onError?.(new Error("Error polling 3DS session"));
7677
7711
  }
7678
7712
  }, interval);
7679
7713
  }
7680
- function threeDSecureSession({ sessionId, appId, callbacks, intervalRef, setIsVisible, }) {
7714
+ function threeDSecureSession({ sessionId, appId, options, intervalRef, setIsVisible, }) {
7681
7715
  async function get() {
7682
7716
  try {
7683
7717
  const response = await fetch(`https://${EV_API_DOMAIN}/frontend/3ds/browser-sessions/${sessionId}`, {
@@ -7703,7 +7737,7 @@ function threeDSecureSession({ sessionId, appId, callbacks, intervalRef, setIsVi
7703
7737
  },
7704
7738
  body: JSON.stringify({ outcome: "cancelled" }),
7705
7739
  });
7706
- callbacks?.onFailure?.(new Error("3DS session cancelled by user"));
7740
+ options?.onFailure?.(new Error("3DS session cancelled by user"));
7707
7741
  stopPolling(intervalRef, setIsVisible);
7708
7742
  }
7709
7743
  catch (error) {
@@ -7718,22 +7752,27 @@ function threeDSecureSession({ sessionId, appId, callbacks, intervalRef, setIsVi
7718
7752
  };
7719
7753
  }
7720
7754
 
7721
- function useThreeDSecure() {
7755
+ function useThreeDSecure(options) {
7722
7756
  const { appId } = useEvervault();
7723
7757
  const intervalRef = React.useRef(null);
7724
7758
  const [session, setSession] = React.useState(null);
7725
7759
  const [isVisible, setIsVisible] = React.useState(false);
7726
- const start = React.useCallback((sessionId, callbacks) => {
7760
+ const failOnChallenge = options?.failOnChallenge ?? false;
7761
+ const start = React.useCallback((sessionId, options) => {
7762
+ const startOptions = {
7763
+ ...options,
7764
+ failOnChallenge: options?.failOnChallenge ?? failOnChallenge,
7765
+ };
7727
7766
  const session = threeDSecureSession({
7728
7767
  sessionId,
7729
7768
  appId,
7730
- callbacks,
7769
+ options: startOptions,
7731
7770
  intervalRef,
7732
7771
  setIsVisible,
7733
7772
  });
7734
7773
  setSession(session);
7735
- startSession(session, callbacks, intervalRef, setIsVisible);
7736
- }, [appId]);
7774
+ startSession(session, startOptions, intervalRef, setIsVisible);
7775
+ }, [appId, failOnChallenge]);
7737
7776
  const cancel = React.useCallback(async () => {
7738
7777
  if (session) {
7739
7778
  await session.cancel();