@basis-theory/web-elements 1.5.0 → 1.7.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.
Files changed (47) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/bundle/index.js +1 -1
  3. package/dist/main/index.js +591 -3
  4. package/dist/module/module.js +608 -4
  5. package/dist/package.json +1 -1
  6. package/dist/types/index.d.ts +126 -84
  7. package/dist/types/{common → src/common}/BasisTheoryValidationError.d.ts +1 -1
  8. package/dist/types/{elements → src/elements}/loadElements.d.ts +1 -1
  9. package/dist/types/src/index.d.ts +8 -0
  10. package/dist/types/{types → src/types}/elements/elements.d.ts +3 -1
  11. package/dist/types/src/types/elements/services/sessions.d.ts +11 -0
  12. package/dist/types/{types → src/types}/elements/services/token-intents.d.ts +2 -2
  13. package/dist/types/{types → src/types}/elements/services/tokenize.d.ts +2 -2
  14. package/dist/types/{types → src/types}/elements/services/tokens.d.ts +2 -2
  15. package/dist/types/{types → src/types}/elements/shared.d.ts +1 -1
  16. package/dist/types/src/types/index.d.ts +1 -0
  17. package/dist/types/{types → src/types}/models/token-intents.d.ts +1 -1
  18. package/dist/types/src/version.d.ts +1 -0
  19. package/dist/types/tsconfig.tsbuildinfo +1 -0
  20. package/package.json +1 -1
  21. package/dist/types/version.d.ts +0 -1
  22. /package/dist/types/{BasisTheory.d.ts → src/BasisTheory.d.ts} +0 -0
  23. /package/dist/types/{common → src/common}/BasisTheoryApiError.d.ts +0 -0
  24. /package/dist/types/{common → src/common}/HttpClientError.d.ts +0 -0
  25. /package/dist/types/{common → src/common}/index.d.ts +0 -0
  26. /package/dist/types/{common → src/common}/logging.d.ts +0 -0
  27. /package/dist/types/{elements → src/elements}/constants.d.ts +0 -0
  28. /package/dist/types/{elements → src/elements}/getOrCreateScriptElement.d.ts +0 -0
  29. /package/dist/types/{elements → src/elements}/index.d.ts +0 -0
  30. /package/dist/types/{types → src/types}/elements/cardTypes.d.ts +0 -0
  31. /package/dist/types/{types → src/types}/elements/events.d.ts +0 -0
  32. /package/dist/types/{types → src/types}/elements/index.d.ts +0 -0
  33. /package/dist/types/{types → src/types}/elements/options.d.ts +0 -0
  34. /package/dist/types/{types → src/types}/elements/services/index.d.ts +0 -0
  35. /package/dist/types/{types → src/types}/elements/services/proxy.d.ts +0 -0
  36. /package/dist/types/{types → src/types}/elements/services/shared.d.ts +0 -0
  37. /package/dist/types/{types → src/types}/elements/styles.d.ts +0 -0
  38. /package/dist/types/{types → src/types}/models/bin-details.d.ts +0 -0
  39. /package/dist/types/{types → src/types}/models/cards.d.ts +0 -0
  40. /package/dist/types/{types → src/types}/models/index.d.ts +0 -0
  41. /package/dist/types/{types → src/types}/models/shared.d.ts +0 -0
  42. /package/dist/types/{types → src/types}/models/tokenize.d.ts +0 -0
  43. /package/dist/types/{types → src/types}/models/tokens.d.ts +0 -0
  44. /package/dist/types/{types → src/types}/models/util.d.ts +0 -0
  45. /package/dist/types/{types → src/types}/sdk/index.d.ts +0 -0
  46. /package/dist/types/{types → src/types}/sdk/services/http.d.ts +0 -0
  47. /package/dist/types/{types → src/types}/sdk/services/index.d.ts +0 -0
@@ -2,7 +2,7 @@ import { Properties } from "csstype";
2
2
  type CardBrandId = 'american-express' | 'diners-club' | 'discover' | 'elo' | 'hiper' | 'hipercard' | 'jcb' | 'maestro' | 'mastercard' | 'mir' | 'unionpay' | 'visa';
3
3
  type CardBrandNiceType = 'American Express' | 'Diners Club' | 'Discover' | 'Elo' | 'Hiper' | 'Hipercard' | 'JCB' | 'Maestro' | 'Mastercard' | 'Mir' | 'UnionPay' | 'Visa';
4
4
  type SecurityCodeLabel = 'CVV' | 'CVC' | 'CID' | 'CVN' | 'CVE' | 'CVP2';
5
- type CreditCardType = {
5
+ export type CreditCardType = {
6
6
  code: {
7
7
  size: number;
8
8
  name: SecurityCodeLabel | string;
@@ -13,6 +13,19 @@ type CreditCardType = {
13
13
  patterns: (number | [number, number])[];
14
14
  type: CardBrandId | string;
15
15
  };
16
+ export const VISA: CreditCardType;
17
+ export const MASTERCARD: CreditCardType;
18
+ export const AMERICAN_EXPRESS: CreditCardType;
19
+ export const DINERS_CLUB: CreditCardType;
20
+ export const DISCOVER: CreditCardType;
21
+ export const JCB: CreditCardType;
22
+ export const UNION_PAY: CreditCardType;
23
+ export const MAESTRO: CreditCardType;
24
+ export const ELO: CreditCardType;
25
+ export const MIR: CreditCardType;
26
+ export const HIPER: CreditCardType;
27
+ export const HIPERCARD: CreditCardType;
28
+ export const DEFAULT_CARD_TYPES: CreditCardType[];
16
29
  interface RequestConfig {
17
30
  headers?: Record<string, string>;
18
31
  }
@@ -24,24 +37,33 @@ interface HttpClient {
24
37
  delete(url: string, config?: RequestConfig): Promise<unknown>;
25
38
  }
26
39
  declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
40
+ declare const CARD_ICON_POSITIONS: readonly ["left", "right", "none"];
27
41
  declare const AUTOCOMPLETE_VALUES: readonly ["additional-name", "address-level1", "address-level2", "address-level3", "address-level4", "address-line1", "address-line2", "address-line3", "bday-day", "bday-month", "bday-year", "bday", "billing", "cc-additional-name", "cc-csc", "cc-exp-month", "cc-exp-year", "cc-exp", "cc-family-name", "cc-given-name", "cc-name", "cc-number", "cc-type", "country-name", "country", "current-password", "email", "family-name", "fax", "given-name", "home", "honorific-prefix", "honorific-suffix", "language", "mobile", "name", "new-password", "nickname", "off", "on", "one-time-code", "organization-title", "organization", "page", "postal-code", "sex", "shipping", "street-address", "tel-area-code", "tel-country-code", "tel-extension", "tel-local-prefix", "tel-local-suffix", "tel-local", "tel-national", "tel", "transaction-amount", "transaction-currency", "url", "username", "work"];
28
- type FieldErrorType = 'incomplete' | 'invalid';
29
- interface Targeted {
42
+ export type FieldErrorType = 'incomplete' | 'invalid';
43
+ export type ConfigErrorType = 'missing-configuration' | 'missing-permission' | 'invalid-configuration';
44
+ export interface ConfigError {
45
+ type: ConfigErrorType;
46
+ message: string;
47
+ }
48
+ export interface Targeted {
30
49
  targetId: string;
31
50
  }
32
- type ListenableKey = 'Escape' | 'Enter';
33
- interface FieldError {
51
+ export type ListenableKey = 'Escape' | 'Enter';
52
+ export interface FieldError {
34
53
  targetId: string;
35
54
  type: FieldErrorType;
36
55
  }
37
- interface ElementMetadata {
56
+ export interface PropertyError {
57
+ type: FieldErrorType;
58
+ }
59
+ export interface ElementMetadata {
38
60
  complete: boolean;
39
61
  valid: boolean;
40
62
  maskSatisfied?: boolean;
41
63
  empty: boolean;
42
64
  errors?: FieldError[] | Omit<FieldError, 'targetId'>[];
43
65
  }
44
- interface CardMetadata {
66
+ export interface CardMetadata {
45
67
  cardBrand: Brand;
46
68
  cardLast4?: string;
47
69
  cardBin?: string;
@@ -49,87 +71,93 @@ interface CardMetadata {
49
71
  /**
50
72
  * Card brands type
51
73
  */
52
- type Brand = typeof CARD_BRANDS[number];
74
+ export type Brand = typeof CARD_BRANDS[number];
75
+ /**
76
+ * Icon position for card number element
77
+ */
78
+ export type CardIconPosition = typeof CARD_ICON_POSITIONS[number];
53
79
  /**
54
80
  * Values for the element input autocomplete attribute
55
81
  */
56
- type AutoCompleteValue = typeof AUTOCOMPLETE_VALUES[number];
82
+ export type AutoCompleteValue = typeof AUTOCOMPLETE_VALUES[number];
57
83
  /**
58
84
  * Type used for detokenization responses stored on Data Elements
59
85
  */
60
- type DataElementReference = {
86
+ export type DataElementReference = {
61
87
  correlationId: string;
62
88
  elementId: string;
63
89
  path: string;
64
90
  };
65
- type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown';
66
- interface BaseEvent<T extends EventType> {
91
+ export type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown';
92
+ export interface BaseEvent<T extends EventType> {
67
93
  type: T;
68
94
  }
69
- type ReadyEvent = BaseEvent<'ready'>;
70
- type ChangeEvent = BaseEvent<'change'> & {
95
+ export type ReadyEvent = BaseEvent<'ready'>;
96
+ export type ChangeEvent = BaseEvent<'change'> & {
71
97
  empty: boolean;
72
98
  complete: boolean;
73
99
  valid?: boolean;
74
100
  maskSatisfied?: boolean;
75
101
  errors?: FieldError[];
76
102
  };
77
- type CardChangeEvent = ChangeEvent & {
103
+ export type CardChangeEvent = ChangeEvent & {
78
104
  cardBrand: Brand;
79
105
  cardLast4?: string;
80
106
  cardBin?: string;
81
107
  };
82
- type InputFocusEvent = BaseEvent<'focus'> & Targeted;
83
- type InputBlurEvent = BaseEvent<'blur'> & Targeted;
84
- type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
108
+ export type InputFocusEvent = BaseEvent<'focus'> & Targeted;
109
+ export type InputBlurEvent = BaseEvent<'blur'> & Targeted;
110
+ export type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
85
111
  key: ListenableKey;
86
112
  } & Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey'>;
87
- type BaseElementEvents = ReadyEvent | InputFocusEvent | InputBlurEvent | InputKeydownEvent;
88
- type TextElementEvents = BaseElementEvents | ChangeEvent;
89
- type CardElementEvents = BaseElementEvents | CardChangeEvent;
90
- type CardNumberElementEvents = BaseElementEvents | CardChangeEvent;
91
- type CardExpirationDateElementEvents = BaseElementEvents | ChangeEvent;
92
- type CardVerificationCodeElementEvents = BaseElementEvents | ChangeEvent;
113
+ export type BaseElementEvents = ReadyEvent | InputFocusEvent | InputBlurEvent | InputKeydownEvent;
114
+ export type TextElementEvents = BaseElementEvents | ChangeEvent;
115
+ export type CardElementEvents = BaseElementEvents | CardChangeEvent;
116
+ export type CardNumberElementEvents = BaseElementEvents | CardChangeEvent;
117
+ export type CardExpirationDateElementEvents = BaseElementEvents | ChangeEvent;
118
+ export type CardVerificationCodeElementEvents = BaseElementEvents | ChangeEvent;
93
119
  /**
94
120
  * Utility type that helps find a Union type based on a `type` property
95
121
  */
96
122
  type FindByType<Union, Type> = Union extends {
97
123
  type: Type;
98
124
  } ? Union : never;
99
- type ElementEventListener<Events, Type> = (event: FindByType<Events, Type>) => void;
100
- interface Subscription {
125
+ export type ElementEventListener<Events, Type> = (event: FindByType<Events, Type>) => void;
126
+ export interface Subscription {
101
127
  unsubscribe(): void;
102
128
  }
103
- declare const SAFE_CSS_PROPERTIES: readonly ["backgroundColor", "color", "fontFamily", "fontSize", "fontSmooth", "fontStyle", "fontVariant", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "padding", "textDecoration", "textShadow", "textTransform"];
104
- type SafeCSSProperty = typeof SAFE_CSS_PROPERTIES[number];
105
- type SafeStyle = Pick<Properties, SafeCSSProperty>;
106
- declare const CARD_ELEMENT_STYLE_VARIANT_SELECTORS: readonly [":hover", ":focus", ":read-only", "::placeholder", "::selection", ":disabled"];
107
- type CardElementStyleVariantSelector = typeof CARD_ELEMENT_STYLE_VARIANT_SELECTORS[number];
108
- type CardElementStyleVariantStyle = SafeStyle & Partial<Record<CardElementStyleVariantSelector, SafeStyle>>;
109
- declare const CARD_ELEMENT_STYLE_VARIANTS: readonly ["base", "complete", "invalid", "empty"];
110
- declare const CARD_ELEMENT_STYLE_FONTS_ATTR: "fonts";
111
- type CardElementStyleVariant = typeof CARD_ELEMENT_STYLE_VARIANTS[number];
129
+ export const SAFE_CSS_PROPERTIES: readonly ["backgroundColor", "color", "fontFamily", "fontSize", "fontSmooth", "fontStyle", "fontVariant", "fontWeight", "lineHeight", "letterSpacing", "textAlign", "padding", "textDecoration", "textShadow", "textTransform"];
130
+ export type SafeCSSProperty = typeof SAFE_CSS_PROPERTIES[number];
131
+ export const SAFE_CSS_PROPERTIES_ALTERNATES: Partial<Record<SafeCSSProperty, string[]>>;
132
+ export const SAFE_CSS_PROPERTIES_WITH_ALTERNATES: string[];
133
+ export type SafeStyle = Pick<Properties, SafeCSSProperty>;
134
+ export const CARD_ELEMENT_STYLE_VARIANT_SELECTORS: readonly [":hover", ":focus", ":read-only", "::placeholder", "::selection", ":disabled"];
135
+ export type CardElementStyleVariantSelector = typeof CARD_ELEMENT_STYLE_VARIANT_SELECTORS[number];
136
+ export type CardElementStyleVariantStyle = SafeStyle & Partial<Record<CardElementStyleVariantSelector, SafeStyle>>;
137
+ export const CARD_ELEMENT_STYLE_VARIANTS: readonly ["base", "complete", "invalid", "empty"];
138
+ export const CARD_ELEMENT_STYLE_FONTS_ATTR: "fonts";
139
+ export type CardElementStyleVariant = typeof CARD_ELEMENT_STYLE_VARIANTS[number];
112
140
  type CardElementStyleFontAttr = typeof CARD_ELEMENT_STYLE_FONTS_ATTR;
113
141
  type FontSource = string;
114
- type FontSources = FontSource[];
115
- type Fonts = Record<CardElementStyleFontAttr, FontSources>;
116
- type CardElementStyle = Partial<Record<CardElementStyleVariant, CardElementStyleVariantStyle> & Fonts>;
117
- type ElementStyle = CardElementStyle;
118
- type CopyIconStyles = {
142
+ export type FontSources = FontSource[];
143
+ export type Fonts = Record<CardElementStyleFontAttr, FontSources>;
144
+ export type CardElementStyle = Partial<Record<CardElementStyleVariant, CardElementStyleVariantStyle> & Fonts>;
145
+ export type ElementStyle = CardElementStyle;
146
+ export type CopyIconStyles = {
119
147
  size?: string;
120
148
  color?: string;
121
149
  successColor?: string;
122
150
  };
123
- declare const ELEMENTS_TYPES: readonly ["card", "cardExpirationDate", "cardNumber", "cardVerificationCode", "data", "text"];
124
- type ElementType = typeof ELEMENTS_TYPES[number];
125
- interface ElementInternalOptions {
151
+ export const ELEMENTS_TYPES: readonly ["card", "cardExpirationDate", "cardNumber", "cardVerificationCode", "data", "text"];
152
+ export type ElementType = typeof ELEMENTS_TYPES[number];
153
+ export interface ElementInternalOptions {
126
154
  apiKey: string | undefined;
127
155
  baseUrl: string;
128
156
  type: ElementType;
129
157
  useNgApi: boolean | undefined;
130
158
  useSameOriginApi: boolean | undefined;
131
159
  }
132
- enum InputMode {
160
+ export enum InputMode {
133
161
  DECIMAL = "decimal",
134
162
  EMAIL = "email",
135
163
  NONE = "none",
@@ -139,7 +167,7 @@ enum InputMode {
139
167
  TEXT = "text",
140
168
  URL = "url"
141
169
  }
142
- interface SanitizedElementOptions {
170
+ export interface SanitizedElementOptions {
143
171
  ariaDescription?: string;
144
172
  ariaLabel?: string;
145
173
  autoComplete?: AutoCompleteValue;
@@ -163,56 +191,56 @@ interface SanitizedElementOptions {
163
191
  validation?: RegExp;
164
192
  value?: CardElementValue<'static'> | CardExpirationDateValue<'static'> | string;
165
193
  }
166
- type ElementOptions = ElementInternalOptions & SanitizedElementOptions;
167
- type Transform = RegExp | [RegExp, string?] | null;
194
+ export type ElementOptions = ElementInternalOptions & SanitizedElementOptions;
195
+ export type Transform = RegExp | [RegExp, string?] | null;
168
196
  interface TransformOption {
169
197
  transform?: Transform;
170
198
  }
171
199
  interface AutoCompleteOption {
172
200
  autoComplete?: AutoCompleteValue;
173
201
  }
174
- type CustomizableElementOptions = Pick<ElementOptions, 'cardTypes' | 'copyIconStyles' | 'disabled' | 'enableCopy' | 'inputMode' | 'readOnly' | 'skipLuhnValidation' | 'style' | 'validateOnChange'> & AutoCompleteOption;
202
+ export type CustomizableElementOptions = Pick<ElementOptions, 'cardTypes' | 'copyIconStyles' | 'disabled' | 'enableCopy' | 'inputMode' | 'readOnly' | 'skipLuhnValidation' | 'style' | 'validateOnChange'> & AutoCompleteOption;
175
203
  type ElementValueType = 'static' | 'reference';
176
- interface CardElementValue<T extends ElementValueType> {
204
+ export interface CardElementValue<T extends ElementValueType> {
177
205
  cvc?: T extends 'reference' ? DataElementReference : string;
178
206
  expiration_month?: T extends 'reference' ? DataElementReference : number;
179
207
  expiration_year?: T extends 'reference' ? DataElementReference : number;
180
208
  number?: T extends 'reference' ? DataElementReference : string;
181
209
  }
182
- interface CardElementPlaceholder {
210
+ export interface CardElementPlaceholder {
183
211
  cardNumber?: string;
184
212
  cardExpirationDate?: string;
185
213
  cardSecurityCode?: string;
186
214
  }
187
- interface CardExpirationDateValue<T extends ElementValueType> {
215
+ export interface CardExpirationDateValue<T extends ElementValueType> {
188
216
  month: T extends 'reference' ? DataElementReference : number;
189
217
  year: T extends 'reference' ? DataElementReference : number;
190
218
  }
191
- type CreateCardElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'cardTypes' | 'skipLuhnValidation'> & {
219
+ export type CreateCardElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'cardTypes' | 'skipLuhnValidation'> & {
192
220
  placeholder?: CardElementPlaceholder;
193
221
  value?: CardElementValue<'static'>;
194
222
  };
195
- type UpdateCardElementOptions = Omit<CreateCardElementOptions, 'validateOnChange' | 'enableCopy'>;
196
- type CreateTextElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'mask' | 'maxLength' | 'password' | 'validation'> & TransformOption & Required<Pick<ElementOptions, 'targetId'>> & {
223
+ export type UpdateCardElementOptions = Omit<CreateCardElementOptions, 'validateOnChange' | 'enableCopy'>;
224
+ export type CreateTextElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'mask' | 'maxLength' | 'password' | 'validation'> & TransformOption & Required<Pick<ElementOptions, 'targetId'>> & {
197
225
  'aria-label'?: string;
198
226
  value?: string;
199
227
  };
200
- type UpdateTextElementOptions = Omit<CreateTextElementOptions, 'targetId' | 'mask' | 'validateOnChange'>;
201
- type CreateCardNumberElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'iconPosition' | 'cardTypes' | 'skipLuhnValidation'> & Required<Pick<ElementOptions, 'targetId'>> & {
228
+ export type UpdateTextElementOptions = Omit<CreateTextElementOptions, 'targetId' | 'mask' | 'validateOnChange'>;
229
+ export type CreateCardNumberElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'iconPosition' | 'cardTypes' | 'skipLuhnValidation'> & Required<Pick<ElementOptions, 'targetId'>> & {
202
230
  'aria-label'?: string;
203
231
  value?: string;
204
232
  };
205
- type UpdateCardNumberElementOptions = Omit<CreateCardNumberElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
206
- type CreateCardExpirationDateElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder'> & Required<Pick<ElementOptions, 'targetId'>> & {
233
+ export type UpdateCardNumberElementOptions = Omit<CreateCardNumberElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
234
+ export type CreateCardExpirationDateElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder'> & Required<Pick<ElementOptions, 'targetId'>> & {
207
235
  'aria-label'?: string;
208
236
  value?: CardExpirationDateValue<'static'> | string;
209
237
  };
210
- type UpdateCardExpirationDateElementOptions = Omit<CreateCardExpirationDateElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
211
- type CreateCardVerificationCodeElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'cardBrand'> & Required<Pick<ElementOptions, 'targetId'>> & {
238
+ export type UpdateCardExpirationDateElementOptions = Omit<CreateCardExpirationDateElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
239
+ export type CreateCardVerificationCodeElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'cardBrand'> & Required<Pick<ElementOptions, 'targetId'>> & {
212
240
  'aria-label'?: string;
213
241
  value?: string;
214
242
  };
215
- type UpdateCardVerificationCodeElementOptions = Omit<CreateCardVerificationCodeElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
243
+ export type UpdateCardVerificationCodeElementOptions = Omit<CreateCardVerificationCodeElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
216
244
  interface BinDetails {
217
245
  cardBrand?: string;
218
246
  type?: string;
@@ -308,11 +336,11 @@ type Token<DataType = Primitive> = TokenBase<DataType> & {
308
336
  fingerprint?: string;
309
337
  metadata?: Record<string, string>;
310
338
  };
311
- type CreateToken<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
339
+ type _CreateToken1<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
312
340
  deduplicateToken?: boolean;
313
341
  id?: string;
314
342
  };
315
- type UpdateToken<DataType = Primitive> = Partial<Pick<Token<DataType>, 'data' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
343
+ type _UpdateToken1<DataType = Primitive> = Partial<Pick<Token<DataType>, 'data' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
316
344
  privacy: Omit<TokenPrivacy, 'classification'>;
317
345
  deduplicateToken: boolean;
318
346
  }>;
@@ -320,7 +348,7 @@ type TokenizeObject<DataType = Primitive> = {
320
348
  [key: string]: Primitive | TokenizeObject<DataType> | TokenizeArray<DataType> | DataType;
321
349
  };
322
350
  type TokenizeArray<DataType = Primitive> = Array<Primitive | TokenizeObject<DataType> | TokenizeArray<DataType> | DataType>;
323
- type TokenizeData<DataType = Primitive> = TokenizeArray<DataType> | TokenizeObject<DataType>;
351
+ type _TokenizeData1<DataType = Primitive> = TokenizeArray<DataType> | TokenizeObject<DataType>;
324
352
  interface TokenIntentCardDetails {
325
353
  type: 'card';
326
354
  card: {
@@ -346,7 +374,7 @@ type TokenIntent<DataType = DataObject> = (TokenBase<DataType> & Omit<Auditable,
346
374
  }) & (TokenTypeMap[TokenTypesForTokenIntents] | TokenIntentCardDetails | {
347
375
  type: 'token';
348
376
  });
349
- type CreateTokenIntent<DataType = DataObject> = Pick<TokenIntent<DataType>, 'type' | 'data'>;
377
+ type _CreateTokenIntent1<DataType = DataObject> = Pick<TokenIntent<DataType>, 'type' | 'data'>;
350
378
  interface RequestOptions {
351
379
  apiKey?: string;
352
380
  correlationId?: string;
@@ -361,13 +389,13 @@ type Retrieve<T> = {
361
389
  type Update<T, U> = {
362
390
  update(id: string, model: U, options?: RequestOptions): Promise<T>;
363
391
  };
364
- type _TokenizeData1 = TokenizeData<ElementValue>;
365
- interface Tokenize {
366
- tokenize(tokens: _TokenizeData1, options?: RequestOptions): Promise<TokenizeData>;
392
+ export type TokenizeData = _TokenizeData1<ElementValue>;
393
+ export interface Tokenize {
394
+ tokenize(tokens: TokenizeData, options?: RequestOptions): Promise<_TokenizeData1>;
367
395
  }
368
- type _CreateToken1 = CreateToken<ElementValue>;
369
- type _UpdateToken1 = UpdateToken<ElementValue>;
370
- type Tokens = Create<Token, _CreateToken1> & Retrieve<Token<unknown>> & Update<Token, _UpdateToken1>;
396
+ export type CreateToken = _CreateToken1<ElementValue>;
397
+ export type UpdateToken = _UpdateToken1<ElementValue>;
398
+ export type Tokens = Create<Token, CreateToken> & Retrieve<Token<unknown>> & Update<Token, UpdateToken>;
371
399
  type BasisTheoryProxyHeaders = {
372
400
  [key: string]: string;
373
401
  'BT-PROXY-URL': string;
@@ -379,23 +407,32 @@ type BasisTheoryQueryParams = {
379
407
  'bt-proxy-key': string;
380
408
  };
381
409
  type ProxyQuery = Partial<BasisTheoryQueryParams>;
382
- interface ProxyRequestOptions extends RequestOptions {
410
+ export interface ProxyRequestOptions extends RequestOptions {
383
411
  includeResponseHeaders?: boolean;
384
412
  path?: string;
385
413
  query?: ProxyQuery;
386
414
  headers?: ProxyHeaders;
387
415
  body?: unknown;
388
416
  }
389
- interface Proxy {
417
+ export interface Proxy {
390
418
  get(options?: ProxyRequestOptions): Promise<unknown>;
391
419
  post(options?: ProxyRequestOptions): Promise<unknown>;
392
420
  patch(options?: ProxyRequestOptions): Promise<unknown>;
393
421
  put(options?: ProxyRequestOptions): Promise<unknown>;
394
422
  delete(options?: ProxyRequestOptions): Promise<unknown>;
395
423
  }
396
- type _CreateTokenIntent1 = CreateTokenIntent<ElementValue>;
397
- type TokenIntents = Create<TokenIntent, _CreateTokenIntent1>;
398
- interface BaseElement<UpdateOptions, ElementEvents> {
424
+ export type CreateTokenIntent = _CreateTokenIntent1<ElementValue>;
425
+ export type TokenIntents = Create<TokenIntent, CreateTokenIntent>;
426
+ type CreateSessionResponse = {
427
+ sessionKey: string;
428
+ nonce: string;
429
+ expiresAt: string;
430
+ _debug?: Record<string, unknown>;
431
+ };
432
+ interface Sessions {
433
+ create(options?: RequestOptions): Promise<CreateSessionResponse>;
434
+ }
435
+ export interface BaseElement<UpdateOptions, ElementEvents> {
399
436
  readonly mounted: boolean;
400
437
  readonly metadata: ElementMetadata;
401
438
  mount(selector: string): Promise<void>;
@@ -407,42 +444,43 @@ interface BaseElement<UpdateOptions, ElementEvents> {
407
444
  unmount(): void;
408
445
  on<T extends EventType>(eventType: T, listener: ElementEventListener<ElementEvents, T>): Subscription;
409
446
  }
410
- type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents> & {
447
+ export type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents> & {
411
448
  readonly cardMetadata?: CardMetadata;
412
449
  setValue(value: CardElementValue<'reference'>): void;
413
450
  validate(): void;
414
451
  };
415
- type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents> & {
452
+ export type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents> & {
416
453
  setValueRef(value: TextElement): void;
417
454
  setValue(value: DataElementReference): void;
418
455
  };
419
- type CardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents> & {
456
+ export type CardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents> & {
420
457
  readonly cardMetadata?: CardMetadata;
421
458
  setValueRef(value: CardNumberElement): void;
422
459
  setValue(value: DataElementReference): void;
423
460
  };
424
- type CardExpirationDateElement = BaseElement<UpdateCardExpirationDateElementOptions, CardExpirationDateElementEvents> & {
461
+ export type CardExpirationDateElement = BaseElement<UpdateCardExpirationDateElementOptions, CardExpirationDateElementEvents> & {
425
462
  setValueRef(value: CardExpirationDateElement): void;
426
463
  setValue(value: CardExpirationDateValue<'reference'>): void;
427
464
  month(): ElementWrapper<CardExpirationDateElement>;
428
465
  year(): ElementWrapper<CardExpirationDateElement>;
429
466
  format(dateFormat: string): ElementWrapper<CardExpirationDateElement>;
430
467
  };
431
- type CardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents> & {
468
+ export type CardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents> & {
432
469
  setValueRef(value: CardVerificationCodeElement): void;
433
470
  setValue(value: DataElementReference): void;
434
471
  };
435
- type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
472
+ export type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
436
473
  element: T;
437
474
  method?: string;
438
475
  formattingOptions?: {
439
476
  format: string;
440
477
  };
441
478
  };
442
- type ElementValue = TextElement | CardElement | CardNumberElement | CardExpirationDateElement | CardVerificationCodeElement | ElementWrapper;
443
- interface BasisTheoryElements {
479
+ export type ElementValue = TextElement | CardElement | CardNumberElement | CardExpirationDateElement | CardVerificationCodeElement | ElementWrapper;
480
+ export interface BasisTheoryElements {
444
481
  tokens: Tokens;
445
482
  proxy: Proxy;
483
+ sessions: Sessions;
446
484
  tokenIntents: TokenIntents;
447
485
  tokenize: Tokenize;
448
486
  client: HttpClient;
@@ -452,6 +490,10 @@ interface BasisTheoryElements {
452
490
  createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
453
491
  createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
454
492
  }
493
+ export interface BasisTheoryElementsInternal extends BasisTheoryElements {
494
+ init: (apiKey: string | undefined, elementsBaseUrl: string, elementsUseNgApi: boolean | undefined, disableTelemetry: boolean | undefined, elementsUseSameOriginApi: boolean | undefined) => Promise<BasisTheoryElements>;
495
+ hasElement: (payload: unknown) => boolean;
496
+ }
455
497
  declare global {
456
498
  interface Window {
457
499
  BasisTheoryElements?: BasisTheoryElementsInternal;
@@ -1,4 +1,4 @@
1
- import type { FieldError } from '~/types/elements';
1
+ import type { FieldError } from '../types/elements';
2
2
  export declare class BasisTheoryValidationError<Details = Record<string, unknown>> extends Error {
3
3
  readonly details: Details;
4
4
  /**
@@ -1,3 +1,3 @@
1
- import type { BasisTheoryElementsInternal } from '~/types/elements';
1
+ import type { BasisTheoryElementsInternal } from '../types/elements';
2
2
  declare const loadElements: (elementsClientUrl?: string) => Promise<BasisTheoryElementsInternal>;
3
3
  export { loadElements };
@@ -0,0 +1,8 @@
1
+ import { basistheory } from './BasisTheory';
2
+ declare global {
3
+ interface Window {
4
+ basistheory?: typeof basistheory;
5
+ }
6
+ }
7
+ export * from './BasisTheory';
8
+ export * from './types';
@@ -1,8 +1,9 @@
1
- import type { HttpClient } from '~/types/sdk';
1
+ import type { HttpClient } from '../../types/sdk';
2
2
  import type { CardElementEvents, CardExpirationDateElementEvents, CardNumberElementEvents, CardVerificationCodeElementEvents, ElementEventListener, EventType, Subscription, TextElementEvents } from './events';
3
3
  import type { CardElementValue, CardExpirationDateValue, CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardNumberElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, UpdateCardElementOptions, UpdateCardExpirationDateElementOptions, UpdateCardNumberElementOptions, UpdateCardVerificationCodeElementOptions, UpdateTextElementOptions } from './options';
4
4
  import type { Proxy, Tokenize, Tokens, TokenIntents } from './services';
5
5
  import type { CardMetadata, DataElementReference, ElementMetadata } from './shared';
6
+ import { Sessions } from './services/sessions';
6
7
  interface BaseElement<UpdateOptions, ElementEvents> {
7
8
  readonly mounted: boolean;
8
9
  readonly metadata: ElementMetadata;
@@ -51,6 +52,7 @@ type ElementValue = TextElement | CardElement | CardNumberElement | CardExpirati
51
52
  interface BasisTheoryElements {
52
53
  tokens: Tokens;
53
54
  proxy: Proxy;
55
+ sessions: Sessions;
54
56
  tokenIntents: TokenIntents;
55
57
  tokenize: Tokenize;
56
58
  client: HttpClient;
@@ -0,0 +1,11 @@
1
+ import { RequestOptions } from './shared';
2
+ type CreateSessionResponse = {
3
+ sessionKey: string;
4
+ nonce: string;
5
+ expiresAt: string;
6
+ _debug?: Record<string, unknown>;
7
+ };
8
+ interface Sessions {
9
+ create(options?: RequestOptions): Promise<CreateSessionResponse>;
10
+ }
11
+ export { CreateSessionResponse, Sessions };
@@ -1,5 +1,5 @@
1
- import type { ElementValue } from '~/types/elements';
2
- import type { CreateTokenIntent as CreateTokenIntentModel, TokenIntent } from '~/types/models';
1
+ import type { ElementValue } from '../../elements';
2
+ import type { CreateTokenIntent as CreateTokenIntentModel, TokenIntent } from '../../models';
3
3
  import { Create } from './shared';
4
4
  type CreateTokenIntent = CreateTokenIntentModel<ElementValue>;
5
5
  type TokenIntents = Create<TokenIntent, CreateTokenIntent>;
@@ -1,5 +1,5 @@
1
- import type { ElementValue } from '~/types/elements';
2
- import type { TokenizeData as TokenizeDataModel } from '~/types/models';
1
+ import type { ElementValue } from '../';
2
+ import type { TokenizeData as TokenizeDataModel } from '../../models';
3
3
  import { RequestOptions } from './shared';
4
4
  type TokenizeData = TokenizeDataModel<ElementValue>;
5
5
  interface Tokenize {
@@ -1,5 +1,5 @@
1
- import type { ElementValue } from '~/types/elements';
2
- import type { CreateToken as CreateTokenModel, UpdateToken as UpdateTokenModel, Token } from '~/types/models';
1
+ import type { ElementValue } from '../../elements';
2
+ import type { CreateToken as CreateTokenModel, UpdateToken as UpdateTokenModel, Token } from '../../models';
3
3
  import { Create, Retrieve, Update } from './shared';
4
4
  type CreateToken = CreateTokenModel<ElementValue>;
5
5
  type UpdateToken = UpdateTokenModel<ElementValue>;
@@ -1,4 +1,4 @@
1
- import { AUTOCOMPLETE_VALUES, CARD_BRANDS, CARD_ICON_POSITIONS } from '~/elements/constants';
1
+ import { AUTOCOMPLETE_VALUES, CARD_BRANDS, CARD_ICON_POSITIONS } from '../../elements/constants';
2
2
  type FieldErrorType = 'incomplete' | 'invalid';
3
3
  type ConfigErrorType = 'missing-configuration' | 'missing-permission' | 'invalid-configuration';
4
4
  interface ConfigError {
@@ -0,0 +1 @@
1
+ export * from './elements';
@@ -1,4 +1,4 @@
1
- import type { TokenBase, DataObject, Auditable, TokenType } from '~/types/models';
1
+ import type { TokenBase, DataObject, Auditable, TokenType } from '../../types/models';
2
2
  interface TokenIntentCardDetails {
3
3
  type: 'card';
4
4
  card: {
@@ -0,0 +1 @@
1
+ export const version: "1.7.0";