@starfish-codes/hellgate 2.0.0-beta.3 → 2.0.0-beta.5

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,9 +1,9 @@
1
1
  import { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
2
2
  import { HellgateSession } from '../session';
3
3
  import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, TokenizedData } from './typings';
4
- import { CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement } from './ui/elements';
5
- import { CardValue, ChangeEvent, ElementBaseOptions } from './ui/typings';
6
- export type FormFieldState = Omit<ChangeEvent<CardValue>['data'], 'type'>;
4
+ import { CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement, TextElement } from './ui/elements';
5
+ import { ChangeEvent, ElementBaseOptions } from './ui/typings';
6
+ export type FormFieldState = Omit<ChangeEvent<never>['data'], 'type'>;
7
7
  export declare class HellgateCardHandler {
8
8
  session: HellgateSession;
9
9
  private bt;
@@ -18,7 +18,7 @@ export declare class HellgateCardHandler {
18
18
  expiryDate: CardExpirationDateElement;
19
19
  securityCode: CardVerificationCodeElement;
20
20
  };
21
- createTextField: (options?: ElementBaseOptions) => import("./ui/elements/text-element").TextElement;
21
+ createTextField: (options?: ElementBaseOptions) => TextElement;
22
22
  tokenize: () => Promise<TokenizedData>;
23
23
  onStateChange: (fn: (state: FormFieldState) => void) => void;
24
24
  clear: () => void;
@@ -1,3 +1,4 @@
1
+ import { TextElement } from './ui/';
1
2
  import { ElementBaseOptions } from './ui/typings';
2
3
  export type CreateCardFormOptions = Pick<ElementBaseOptions, 'style' | 'disabled' | 'autocomplete' | 'placeholder' | 'ariaLabel'> & {
3
4
  icon?: 'left' | 'right' | 'none';
@@ -7,16 +8,17 @@ export type CreateCardFieldsOptions = Pick<ElementBaseOptions, 'style' | 'disabl
7
8
  expiryDate?: ElementBaseOptions;
8
9
  securityCode?: ElementBaseOptions;
9
10
  };
10
- export type PaymentAdditionalData = {
11
- cardholder_name?: string;
12
- email?: string;
11
+ export type AdditionalDataValue = string | TextElement;
12
+ export type PaymentAdditionalData<FieldValue = AdditionalDataValue> = {
13
+ cardholder_name?: FieldValue;
14
+ email?: FieldValue;
13
15
  billing_address?: {
14
- line1?: string;
15
- line2?: string;
16
- line3?: string;
17
- postal_code?: string;
18
- city?: string;
19
- country?: string;
16
+ line1?: FieldValue;
17
+ line2?: FieldValue;
18
+ line3?: FieldValue;
19
+ postal_code?: FieldValue;
20
+ city?: FieldValue;
21
+ country?: FieldValue;
20
22
  };
21
23
  };
22
24
  export type TokenizeData = Record<string, unknown>;
@@ -4,18 +4,18 @@ export declare abstract class CardElementBase<Value, IframeValue = string> {
4
4
  readonly options: ElementBaseOptions<Value>;
5
5
  private iframe;
6
6
  private subscriptions;
7
- value: Value | null;
8
7
  protected abstract type: ElementType;
9
8
  protected abstract extractValue: (rawValue: IframeValue | null) => Value | null;
10
9
  protected abstract putValue: (rawValue: Value | null) => IframeValue | null;
11
- constructor(options: ElementBaseOptions<Value>);
10
+ constructor(options: ElementBaseOptions<Value>, key?: string);
12
11
  mount(selector: string | Element): Promise<void>;
13
12
  update: ({ ...data }: ElementBaseOptions<Value>) => Promise<void>;
14
13
  clear: () => void;
15
14
  focus: () => void;
16
15
  blur: () => void;
17
16
  unmount: () => void;
18
- on<T extends EventType>(eventType: T, listener: (event: FindByType<Explicit<CardElementEvents<Value>>, T>['data']) => void): Subscription;
17
+ on<T extends EventType>(eventType: T, listener: (event: FindByType<Explicit<CardElementEvents<never>>, T>['data']) => void): Subscription;
18
+ secureValue(key: string): Value | null;
19
19
  private emitEvent;
20
20
  private iframePostMessage;
21
21
  }
@@ -9,6 +9,4 @@ export declare class CardExpirationDateElement extends CardElementBase<CardExpir
9
9
  protected type: ElementType;
10
10
  protected extractValue: typeof extractExpiryDateValue;
11
11
  protected putValue: typeof putExpiryDateValue;
12
- month: () => number | null;
13
- year: () => number | null;
14
12
  }
@@ -2,4 +2,5 @@ export * from './card';
2
2
  export * from './card-expiration-date';
3
3
  export * from './card-number';
4
4
  export * from './card-verification-code';
5
+ export * from './text-element';
5
6
  export * from './utils';
@@ -11,5 +11,6 @@ type Elements = {
11
11
  cardVerificationCode: CardVerificationCodeElement;
12
12
  text: TextElement;
13
13
  };
14
- export declare function createElement<T extends keyof Elements>(type: T, options: ElementBaseOptions): Elements[T];
14
+ export declare function createElement<T extends keyof Elements>(type: T, options: ElementBaseOptions, key?: string): Elements[T];
15
+ export declare function uid(): string;
15
16
  export {};
@@ -16,7 +16,7 @@ type ChangeEvent<Value> = BaseEvent<'change', {
16
16
  complete: boolean;
17
17
  valid?: boolean;
18
18
  error?: string;
19
- value: Value | null;
19
+ value: Value extends never ? never : Value | null;
20
20
  }>;
21
21
  type InputFocusEvent = BaseEvent<'focus'>;
22
22
  type InputBlurEvent = BaseEvent<'blur'>;