@starfish-codes/hellgate 3.3.0 → 3.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.
package/README.md CHANGED
@@ -7,6 +7,6 @@
7
7
 
8
8
  - **Hellgate:** https://hellgate.io/
9
9
 
10
- - **Developer Documentation:** https://developer.hellgate.io/sdks/web-sdk
10
+ - **Developer Documentation:** https://developer.hellgate.io/resources/sdks/WebSDK/web-sdk
11
11
 
12
12
  - **API Reference:** https://api-reference.hellgate.io/
@@ -1,20 +1,20 @@
1
1
  import { BasisTheory as IBasisTheory } from '@basis-theory/basis-theory-js/types/sdk';
2
2
  import { CompleteActionResult, HellgateSession } from '../session';
3
- import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, TokenizeCardConfig, TokenizedData } from './typings';
3
+ import { CreateCardFieldsOptions, CreateCardFormOptions, PaymentAdditionalData, RefreshSecurityCodeSessionStateDTO, TokenizeCardSessionStateDTO, TokenizedData } from './typings';
4
4
  import { CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement, TextElement } from './ui/elements';
5
5
  import { ChangeEvent, ElementBaseOptions } from './ui/typings';
6
6
  export type FormFieldState = Omit<ChangeEvent<never>['data'], 'type'>;
7
+ export type CardHandlerSessionInitState = TokenizeCardSessionStateDTO | RefreshSecurityCodeSessionStateDTO;
7
8
  export declare class HellgateCardHandler {
8
- session: HellgateSession;
9
- private tokenizeConfig;
9
+ session: HellgateSession<CardHandlerSessionInitState>;
10
10
  private bt?;
11
- private cardAdditionalData?;
12
11
  state: FormFieldState;
13
12
  private cardElements;
14
13
  private textElements;
15
14
  private stateChangeHandlers;
16
- static init(session: HellgateSession, tokenizeConfig: TokenizeCardConfig): Promise<HellgateCardHandler>;
17
- constructor(session: HellgateSession, tokenizeConfig: TokenizeCardConfig, bt?: IBasisTheory | undefined, cardAdditionalData?: PaymentAdditionalData<string> | undefined);
15
+ readonly cvcOnlyEnabled: boolean;
16
+ static init(session: HellgateSession<CardHandlerSessionInitState>): Promise<HellgateCardHandler>;
17
+ constructor(session: HellgateSession<CardHandlerSessionInitState>, bt?: IBasisTheory | undefined);
18
18
  createForm: (options?: CreateCardFormOptions) => CardElement;
19
19
  createFormFields: (options?: CreateCardFieldsOptions) => {
20
20
  cardNumber: CardNumberElement;
@@ -22,14 +22,14 @@ export declare class HellgateCardHandler {
22
22
  securityCode: CardVerificationCodeElement;
23
23
  };
24
24
  createTextField: (options?: ElementBaseOptions) => TextElement;
25
- tokenize: () => Promise<TokenizedData | {
26
- token_id: string;
27
- } | null>;
25
+ tokenize: (additionalData: PaymentAdditionalData) => Promise<TokenizedData | null>;
28
26
  onStateChange: (fn: (state: FormFieldState) => void) => void;
29
27
  clear: () => void;
30
28
  reset: () => void;
31
29
  dispose: () => void;
32
30
  process: (additionalData?: PaymentAdditionalData) => Promise<CompleteActionResult>;
31
+ private refreshSecurityCode;
32
+ private getFormValue;
33
33
  private hasFormElements;
34
34
  private disableFormElements;
35
35
  private extractAdditionalData;
@@ -1,13 +1,16 @@
1
1
  import { JWK } from 'jose';
2
2
  import { TextElement } from './ui/';
3
- import { ElementBaseOptions } from './ui/typings';
3
+ import { IconPosition } from './ui/iframe/elements/card-number';
4
+ import { CardSchema, ElementBaseOptions } from './ui/typings';
4
5
  export type CreateCardFormOptions = Pick<ElementBaseOptions, 'style' | 'disabled' | 'autocomplete' | 'placeholder' | 'ariaLabel'> & {
5
- icon?: 'left' | 'right' | 'none';
6
+ icon?: IconPosition;
7
+ schemes?: CardSchema[];
6
8
  };
7
9
  export type CreateCardFieldsOptions = Pick<ElementBaseOptions, 'style' | 'disabled' | 'autocomplete'> & {
8
10
  cardNumber?: ElementBaseOptions;
9
11
  expiryDate?: ElementBaseOptions;
10
12
  securityCode?: ElementBaseOptions;
13
+ schemes?: CardSchema[];
11
14
  };
12
15
  export type AdditionalDataValue = string | TextElement;
13
16
  export type PaymentAdditionalData<FieldValue = AdditionalDataValue> = {
@@ -32,12 +35,11 @@ export type TokenizedData = {
32
35
  enc_payload: string;
33
36
  } | {
34
37
  token_id: string;
38
+ additional_data?: PaymentAdditionalData;
35
39
  };
36
40
  export type TokenizeCardActionDTO = {
37
41
  action: 'tokenize_card';
38
- result: TokenizedData & {
39
- additional_data?: PaymentAdditionalData;
40
- };
42
+ result: TokenizedData;
41
43
  };
42
44
  export type TokenizeCardConfig = {
43
45
  provider: 'guardian';
@@ -58,4 +60,24 @@ export type CardTokenizeData = {
58
60
  expiry_year: number;
59
61
  security_code: string;
60
62
  cardholder_name?: string;
63
+ additional_data: PaymentAdditionalData<string>;
64
+ };
65
+ export type TokenizedCardMaskedData = {
66
+ account_number_last_four: string;
67
+ account_number_length: number;
68
+ issuer_identification_number: string;
69
+ expiry_month: number;
70
+ expiry_year: number;
71
+ scheme: CardSchema;
72
+ jwk: JWK;
73
+ };
74
+ export type RefreshSecurityCodeSessionStateDTO = {
75
+ next_action: 'refresh_security_code';
76
+ data: TokenizedCardMaskedData;
77
+ };
78
+ export type RefreshSecurityCodeActionDTO = {
79
+ action: 'refresh_security_code';
80
+ result: {
81
+ enc_payload: string;
82
+ };
61
83
  };
@@ -3,6 +3,6 @@ export declare const ELEMENTS_INIT_ERROR_MESSAGE = "WebSDK Elements was not prop
3
3
  export declare const ELEMENTS_NON_DOM_ERROR_MESSAGE = "Tried to load WebSDKElements in a non-DOM environment.";
4
4
  export declare const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = "WebSDK Elements did not load properly.";
5
5
  export declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "There was an unknown error when loading WebSDK Elements. Check the console for details.";
6
- export declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
6
+ export declare const CARD_SCHEMAS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay"];
7
7
  export declare const CARD_ICON_POSITIONS: readonly ["left", "right", "none"];
8
8
  export declare const AUTOCOMPLETE_VALUES: readonly ["off", "on"];
@@ -26,6 +26,7 @@ export declare abstract class IframeCardElementBase implements BaseElement<Eleme
26
26
  blur(): void;
27
27
  clear(): void;
28
28
  updateCardType(cardTypeName: string | undefined): void;
29
+ updateState(): void;
29
30
  update(options: ElementBaseOptions): Promise<void>;
30
31
  on<T extends EventType>(eventType: T, listener: ElementEventListener<CardElementEvents<string>, T>): Subscription;
31
32
  private emitEvent;
@@ -9,4 +9,5 @@ export declare class IframeCardNumber extends IframeCardElementBase implements I
9
9
  update(options: ElementBaseOptions): Promise<void>;
10
10
  protected validate(masked: Masked): ElementMetadata & CardNumberAdditionalData;
11
11
  protected renderHTML(): string;
12
+ private getCardType;
12
13
  }
@@ -1 +1,3 @@
1
+ export { CARD_SCHEMAS } from './constants';
1
2
  export * from './elements';
3
+ export { type CardSchema } from './typings';
@@ -1,3 +1,4 @@
1
+ import { CARD_SCHEMAS } from './constants';
1
2
  import { IconPosition } from './iframe/elements/card-number';
2
3
  import { ElementStyle } from './styles';
3
4
  export type ListenableKey = 'Escape' | 'Enter';
@@ -59,10 +60,12 @@ export type ElementBaseOptions<Value = unknown> = {
59
60
  style?: ElementStyle;
60
61
  height?: string;
61
62
  disabled?: boolean;
63
+ cvcOnly?: boolean;
62
64
  autocomplete?: 'on' | 'off';
63
65
  placeholder?: string;
64
66
  ariaLabel?: string;
65
67
  icon?: IconPosition;
68
+ schemes?: CardSchema[];
66
69
  value?: Value;
67
70
  };
68
71
  /**
@@ -85,3 +88,4 @@ export type CardValue = {
85
88
  cvc: string | null;
86
89
  };
87
90
  export type ICardElement<Value = CardValue> = BaseElement<ElementBaseOptions, CardElementEvents<Value>, Value>;
91
+ export type CardSchema = (typeof CARD_SCHEMAS)[number];
@@ -0,0 +1,2 @@
1
+ import { TokenizedCardMaskedData } from '../typings';
2
+ export declare function getMaskedCardNumber(data: TokenizedCardMaskedData): string;