@starfish-codes/hellgate 3.8.0 → 3.9.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,22 +1,28 @@
1
- import { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
2
1
  import { CompleteActionResult, HellgateSession } from '../session';
3
2
  import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, RefreshSecurityCodeSessionStateDTO, TokenizeCardSessionStateDTO, TokenizedData } from './typings';
4
3
  import { CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement, TextElement } from './ui/elements';
4
+ import { CardExpirationMonthElement } from './ui/elements/card-expiration-month';
5
+ import { CardExpirationYearElement } from './ui/elements/card-expiration-year';
5
6
  import { ChangeEvent, ElementBaseOptions } from './ui/typings';
6
7
  export type FormFieldState = Omit<ChangeEvent<never>['data'], 'type'>;
7
8
  export type CardHandlerSessionInitState = TokenizeCardSessionStateDTO | RefreshSecurityCodeSessionStateDTO;
8
9
  export declare class HellgateCardHandler {
9
10
  session: HellgateSession<CardHandlerSessionInitState>;
10
- private bt?;
11
11
  state: FormFieldState;
12
12
  private cardElements;
13
13
  private textElements;
14
14
  private stateChangeHandlers;
15
15
  readonly cvcOnlyEnabled: boolean;
16
16
  static init(session: HellgateSession<CardHandlerSessionInitState>): Promise<HellgateCardHandler>;
17
- constructor(session: HellgateSession<CardHandlerSessionInitState>, bt?: IBasisTheory | undefined);
17
+ constructor(session: HellgateSession<CardHandlerSessionInitState>);
18
18
  createForm: (options?: CreateCardFormOptions) => CardElement;
19
- createFormFields: (options?: CreateCardFieldsOptions) => {
19
+ createFormFields(options: CreateCardFieldsOptions<'separate'>): {
20
+ cardNumber: CardNumberElement;
21
+ expiryMonth: CardExpirationMonthElement;
22
+ expiryYear: CardExpirationYearElement;
23
+ securityCode: CardVerificationCodeElement;
24
+ };
25
+ createFormFields(options: CreateCardFieldsOptions<'combined'>): {
20
26
  cardNumber: CardNumberElement;
21
27
  expiryDate: CardExpirationDateElement;
22
28
  securityCode: CardVerificationCodeElement;
@@ -6,12 +6,19 @@ export type CreateCardFormOptions = Pick<ElementBaseOptions, 'style' | 'disabled
6
6
  icon?: IconPosition;
7
7
  schemes?: CardSchema[];
8
8
  };
9
- export type CreateCardFieldsOptions = Pick<ElementBaseOptions, 'style' | 'disabled' | 'autocomplete'> & {
9
+ export type ExpiryDateElementType = 'combined' | 'separate';
10
+ export type CreateCardFieldsOptions<T extends ExpiryDateElementType = 'combined'> = Pick<ElementBaseOptions, 'style' | 'disabled' | 'autocomplete'> & {
10
11
  cardNumber?: ElementBaseOptions;
11
- expiryDate?: ElementBaseOptions;
12
12
  securityCode?: ElementBaseOptions;
13
13
  schemes?: CardSchema[];
14
- };
14
+ } & (T extends 'separate' ? {
15
+ expiryDateElement: 'separate';
16
+ expiryMonth?: ElementBaseOptions;
17
+ expiryYear?: ElementBaseOptions;
18
+ } : {
19
+ expiryDateElement?: 'combined';
20
+ expiryDate?: ElementBaseOptions;
21
+ });
15
22
  export type AdditionalDataValue = string | TextElement;
16
23
  export type PaymentAdditionalData<FieldValue = AdditionalDataValue> = {
17
24
  cardholder_name?: FieldValue;
@@ -46,9 +53,6 @@ export type TokenizeCardConfig = {
46
53
  api_key: string;
47
54
  base_url: string;
48
55
  jwk: JWK;
49
- } | {
50
- provider: 'basis_theory';
51
- api_key: string;
52
56
  };
53
57
  export type TokenizeCardSessionStateDTO = {
54
58
  next_action: 'tokenize_card';
@@ -0,0 +1,9 @@
1
+ import { ElementType } from '../typings';
2
+ import { CardElementBase } from './base-element';
3
+ export declare class CardExpirationMonthElement extends CardElementBase<number> {
4
+ protected type: ElementType;
5
+ protected extractValue: typeof extractExpiryMonthValue;
6
+ protected putValue: typeof putExpiryMonthValue;
7
+ }
8
+ export declare function extractExpiryMonthValue(rawValue: string | null): number | null;
9
+ export declare function putExpiryMonthValue(rawValue: number | null): string | null;
@@ -0,0 +1,9 @@
1
+ import { ElementType } from '../typings';
2
+ import { CardElementBase } from './base-element';
3
+ export declare class CardExpirationYearElement extends CardElementBase<number> {
4
+ protected type: ElementType;
5
+ protected extractValue: typeof extractExpiryYearValue;
6
+ protected putValue: typeof putExpiryYearValue;
7
+ }
8
+ export declare function extractExpiryYearValue(rawValue: string | null): number | null;
9
+ export declare function putExpiryYearValue(rawValue: number | null): string | null;
@@ -1,6 +1,8 @@
1
1
  import { ElementBaseOptions } from '../typings';
2
2
  import { CardElement } from './card';
3
3
  import { CardExpirationDateElement } from './card-expiration-date';
4
+ import { CardExpirationMonthElement } from './card-expiration-month';
5
+ import { CardExpirationYearElement } from './card-expiration-year';
4
6
  import { CardNumberElement } from './card-number';
5
7
  import { CardVerificationCodeElement } from './card-verification-code';
6
8
  import { TextElement } from './text-element';
@@ -8,6 +10,8 @@ type Elements = {
8
10
  card: CardElement;
9
11
  cardNumber: CardNumberElement;
10
12
  cardExpirationDate: CardExpirationDateElement;
13
+ cardExpirationMonth: CardExpirationMonthElement;
14
+ cardExpirationYear: CardExpirationYearElement;
11
15
  cardVerificationCode: CardVerificationCodeElement;
12
16
  text: TextElement;
13
17
  };
@@ -0,0 +1,10 @@
1
+ import { FactoryArg, Masked } from 'imask';
2
+ import { ElementBaseOptions, ElementMetadata, ElementType, ITextElement } from '../../typings';
3
+ import { IframeCardElementBase } from './base-element';
4
+ export declare class IframeCardExpirationMonth extends IframeCardElementBase implements ITextElement {
5
+ readonly type: ElementType;
6
+ protected options: ElementBaseOptions;
7
+ compiledMask?: Masked;
8
+ protected inputMaskOptions: FactoryArg;
9
+ protected validate(masked: Masked): ElementMetadata;
10
+ }
@@ -0,0 +1,9 @@
1
+ import { FactoryArg, Masked } from 'imask';
2
+ import { ElementBaseOptions, ElementMetadata, ElementType, ITextElement } from '../../typings';
3
+ import { IframeCardElementBase } from './base-element';
4
+ export declare class IframeCardExpirationYear extends IframeCardElementBase implements ITextElement {
5
+ readonly type: ElementType;
6
+ protected options: ElementBaseOptions;
7
+ protected inputMaskOptions: FactoryArg;
8
+ protected validate(masked: Masked): ElementMetadata;
9
+ }
@@ -38,7 +38,7 @@ interface Subscription {
38
38
  unsubscribe(): void;
39
39
  }
40
40
  export type { BaseElementEvents, BaseEvent, CardElementEvents, ChangeEvent, ElementEventListener, EventType, FindByType, InputBlurEvent, InputFocusEvent, InputKeydownEvent, ReadyEvent, Subscription, };
41
- export type ElementType = 'card' | 'cardNumber' | 'cardExpirationDate' | 'cardVerificationCode' | 'text';
41
+ export type ElementType = 'card' | 'cardNumber' | 'cardExpirationDate' | 'cardExpirationMonth' | 'cardExpirationYear' | 'cardVerificationCode' | 'text';
42
42
  export declare const ELEMENT_TYPES: ElementType[];
43
43
  export declare enum CardValidationError {
44
44
  NOT_COMPLETE = "NOT_COMPLETE",
@@ -76,6 +76,7 @@ export type ElementBaseOptions<Value = unknown> = {
76
76
  schemes?: CardSchema[];
77
77
  value?: Value;
78
78
  cardType?: string;
79
+ expiryYear?: string;
79
80
  };
80
81
  /**
81
82
  * Card brands type