@basis-theory/web-elements 1.11.2 → 1.11.4
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/CHANGELOG.md +20 -0
- package/dist/bundle/index.js +1 -1
- package/dist/main/index.js +69 -4
- package/dist/module/module.js +70 -5
- package/dist/package.json +3 -4
- package/dist/types/index.d.ts +541 -3
- package/package.json +7 -9
- package/dist/types/BasisTheory.d.ts +0 -9
- package/dist/types/common/BasisTheoryApiError.d.ts +0 -5
- package/dist/types/common/BasisTheoryValidationError.d.ts +0 -13
- package/dist/types/common/HttpClientError.d.ts +0 -6
- package/dist/types/common/index.d.ts +0 -3
- package/dist/types/common/logging.d.ts +0 -8
- package/dist/types/elements/constants.d.ts +0 -9
- package/dist/types/elements/getOrCreateScriptElement.d.ts +0 -1
- package/dist/types/elements/index.d.ts +0 -2
- package/dist/types/elements/loadElements.d.ts +0 -3
- package/dist/types/types/elements/cardTypes.d.ts +0 -29
- package/dist/types/types/elements/elements.d.ts +0 -74
- package/dist/types/types/elements/events.d.ts +0 -40
- package/dist/types/types/elements/index.d.ts +0 -7
- package/dist/types/types/elements/options.d.ts +0 -98
- package/dist/types/types/elements/services/index.d.ts +0 -4
- package/dist/types/types/elements/services/proxy.d.ts +0 -27
- package/dist/types/types/elements/services/sessions.d.ts +0 -11
- package/dist/types/types/elements/services/shared.d.ts +0 -21
- package/dist/types/types/elements/services/token-intents.d.ts +0 -6
- package/dist/types/types/elements/services/tokenize.d.ts +0 -8
- package/dist/types/types/elements/services/tokens.d.ts +0 -7
- package/dist/types/types/elements/shared.d.ts +0 -51
- package/dist/types/types/elements/styles.d.ts +0 -25
- package/dist/types/types/index.d.ts +0 -2
- package/dist/types/types/models/bin-details.d.ts +0 -38
- package/dist/types/types/models/cards.d.ts +0 -12
- package/dist/types/types/models/index.d.ts +0 -7
- package/dist/types/types/models/shared.d.ts +0 -22
- package/dist/types/types/models/token-intents.d.ts +0 -29
- package/dist/types/types/models/tokenize.d.ts +0 -7
- package/dist/types/types/models/tokens.d.ts +0 -53
- package/dist/types/types/models/util.d.ts +0 -11
- package/dist/types/types/sdk/index.d.ts +0 -1
- package/dist/types/types/sdk/services/http.d.ts +0 -11
- package/dist/types/types/sdk/services/index.d.ts +0 -1
- package/dist/types/version.d.ts +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,8 +1,546 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Properties } from "csstype";
|
|
2
|
+
type CardBrandId = 'american-express' | 'diners-club' | 'discover' | 'elo' | 'hiper' | 'hipercard' | 'jcb' | 'maestro' | 'mastercard' | 'mir' | 'unionpay' | 'visa';
|
|
3
|
+
type CardBrandNiceType = 'American Express' | 'Diners Club' | 'Discover' | 'Elo' | 'Hiper' | 'Hipercard' | 'JCB' | 'Maestro' | 'Mastercard' | 'Mir' | 'UnionPay' | 'Visa';
|
|
4
|
+
type SecurityCodeLabel = 'CVV' | 'CVC' | 'CID' | 'CVN' | 'CVE' | 'CVP2';
|
|
5
|
+
export type CreditCardType = {
|
|
6
|
+
code: {
|
|
7
|
+
size: number;
|
|
8
|
+
name: SecurityCodeLabel | string;
|
|
9
|
+
};
|
|
10
|
+
gaps: number[];
|
|
11
|
+
lengths: number[];
|
|
12
|
+
niceType: CardBrandNiceType | string;
|
|
13
|
+
patterns: (number | [number, number])[];
|
|
14
|
+
type: CardBrandId | string;
|
|
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[];
|
|
29
|
+
export interface RequestConfig {
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
}
|
|
32
|
+
export interface HttpClient {
|
|
33
|
+
post(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
|
|
34
|
+
put(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
|
|
35
|
+
patch(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
|
|
36
|
+
get(url: string, config?: RequestConfig): Promise<unknown>;
|
|
37
|
+
delete(url: string, config?: RequestConfig): Promise<unknown>;
|
|
38
|
+
}
|
|
39
|
+
export 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"];
|
|
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"];
|
|
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 {
|
|
49
|
+
targetId: string;
|
|
50
|
+
}
|
|
51
|
+
export type ListenableKey = 'Escape' | 'Enter';
|
|
52
|
+
export interface FieldError {
|
|
53
|
+
targetId: string;
|
|
54
|
+
type: FieldErrorType;
|
|
55
|
+
}
|
|
56
|
+
export interface PropertyError {
|
|
57
|
+
type: FieldErrorType;
|
|
58
|
+
}
|
|
59
|
+
export interface ElementMetadata {
|
|
60
|
+
complete: boolean;
|
|
61
|
+
valid: boolean;
|
|
62
|
+
maskSatisfied?: boolean;
|
|
63
|
+
empty: boolean;
|
|
64
|
+
errors?: FieldError[] | Omit<FieldError, 'targetId'>[];
|
|
65
|
+
}
|
|
66
|
+
export interface CardMetadata {
|
|
67
|
+
cardBrand: Brand;
|
|
68
|
+
cardLast4?: string;
|
|
69
|
+
cardBin?: string;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Card brands type
|
|
73
|
+
*/
|
|
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];
|
|
79
|
+
/**
|
|
80
|
+
* Values for the element input autocomplete attribute
|
|
81
|
+
*/
|
|
82
|
+
export type AutoCompleteValue = (typeof AUTOCOMPLETE_VALUES)[number];
|
|
83
|
+
/**
|
|
84
|
+
* Type used for detokenization responses stored on Data Elements
|
|
85
|
+
*/
|
|
86
|
+
export type DataElementReference = {
|
|
87
|
+
correlationId: string;
|
|
88
|
+
elementId: string;
|
|
89
|
+
path: string;
|
|
90
|
+
};
|
|
91
|
+
export type EventType = 'ready' | 'change' | 'focus' | 'blur' | 'keydown';
|
|
92
|
+
export interface BaseEvent<T extends EventType> {
|
|
93
|
+
type: T;
|
|
94
|
+
}
|
|
95
|
+
export type ReadyEvent = BaseEvent<'ready'>;
|
|
96
|
+
export type ChangeEvent = BaseEvent<'change'> & {
|
|
97
|
+
empty: boolean;
|
|
98
|
+
complete: boolean;
|
|
99
|
+
valid?: boolean;
|
|
100
|
+
maskSatisfied?: boolean;
|
|
101
|
+
errors?: FieldError[];
|
|
102
|
+
};
|
|
103
|
+
export type CardChangeEvent = ChangeEvent & {
|
|
104
|
+
cardBrand: Brand;
|
|
105
|
+
cardLast4?: string;
|
|
106
|
+
cardBin?: string;
|
|
107
|
+
};
|
|
108
|
+
export type InputFocusEvent = BaseEvent<'focus'> & Targeted;
|
|
109
|
+
export type InputBlurEvent = BaseEvent<'blur'> & Targeted;
|
|
110
|
+
export type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
|
|
111
|
+
key: ListenableKey;
|
|
112
|
+
} & Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'shiftKey' | 'metaKey'>;
|
|
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;
|
|
119
|
+
/**
|
|
120
|
+
* Utility type that helps find a Union type based on a `type` property
|
|
121
|
+
*/
|
|
122
|
+
type FindByType<Union, Type> = Union extends {
|
|
123
|
+
type: Type;
|
|
124
|
+
} ? Union : never;
|
|
125
|
+
export type ElementEventListener<Events, Type> = (event: FindByType<Events, Type>) => void;
|
|
126
|
+
export interface Subscription {
|
|
127
|
+
unsubscribe(): void;
|
|
128
|
+
}
|
|
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];
|
|
140
|
+
type CardElementStyleFontAttr = typeof CARD_ELEMENT_STYLE_FONTS_ATTR;
|
|
141
|
+
type FontSource = string;
|
|
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 = {
|
|
147
|
+
size?: string;
|
|
148
|
+
color?: string;
|
|
149
|
+
successColor?: string;
|
|
150
|
+
};
|
|
151
|
+
export const ELEMENTS_TYPES: readonly ["card", "cardExpirationDate", "cardNumber", "cardVerificationCode", "data", "text"];
|
|
152
|
+
export type ElementType = (typeof ELEMENTS_TYPES)[number];
|
|
153
|
+
export interface ElementInternalOptions {
|
|
154
|
+
apiKey: string | undefined;
|
|
155
|
+
baseUrl: string;
|
|
156
|
+
type: ElementType;
|
|
157
|
+
useNgApi: boolean | undefined;
|
|
158
|
+
useSameOriginApi: boolean | undefined;
|
|
159
|
+
}
|
|
160
|
+
export enum InputMode {
|
|
161
|
+
DECIMAL = "decimal",
|
|
162
|
+
EMAIL = "email",
|
|
163
|
+
NONE = "none",
|
|
164
|
+
NUMERIC = "numeric",
|
|
165
|
+
SEARCH = "search",
|
|
166
|
+
TEL = "tel",
|
|
167
|
+
TEXT = "text",
|
|
168
|
+
URL = "url"
|
|
169
|
+
}
|
|
170
|
+
export interface SanitizedElementOptions {
|
|
171
|
+
ariaDescription?: string;
|
|
172
|
+
ariaLabel?: string;
|
|
173
|
+
autoComplete?: AutoCompleteValue;
|
|
174
|
+
cardBrand?: string;
|
|
175
|
+
cardTypes?: CreditCardType[];
|
|
176
|
+
copyIconStyles?: CopyIconStyles;
|
|
177
|
+
disabled?: boolean;
|
|
178
|
+
enableCopy?: boolean;
|
|
179
|
+
iconPosition?: string;
|
|
180
|
+
inputMode?: `${InputMode}`;
|
|
181
|
+
mask?: (RegExp | string)[];
|
|
182
|
+
maxLength?: HTMLInputElement['maxLength'];
|
|
183
|
+
password?: boolean;
|
|
184
|
+
placeholder?: string;
|
|
185
|
+
readOnly?: boolean;
|
|
186
|
+
skipLuhnValidation?: boolean;
|
|
187
|
+
style?: ElementStyle;
|
|
188
|
+
targetId?: string;
|
|
189
|
+
transform?: [RegExp, string] | null;
|
|
190
|
+
validateOnChange?: boolean;
|
|
191
|
+
validation?: RegExp;
|
|
192
|
+
value?: CardElementValue<'static'> | CardExpirationDateValue<'static'> | string;
|
|
193
|
+
}
|
|
194
|
+
export type ElementOptions = ElementInternalOptions & SanitizedElementOptions;
|
|
195
|
+
export type Transform = RegExp | [RegExp, string?] | null;
|
|
196
|
+
interface TransformOption {
|
|
197
|
+
transform?: Transform;
|
|
198
|
+
}
|
|
199
|
+
interface AutoCompleteOption {
|
|
200
|
+
autoComplete?: AutoCompleteValue;
|
|
201
|
+
}
|
|
202
|
+
export type CustomizableElementOptions = Pick<ElementOptions, 'cardTypes' | 'copyIconStyles' | 'disabled' | 'enableCopy' | 'inputMode' | 'readOnly' | 'skipLuhnValidation' | 'style' | 'validateOnChange'> & AutoCompleteOption;
|
|
203
|
+
type ElementValueType = 'static' | 'reference';
|
|
204
|
+
export interface CardElementValue<T extends ElementValueType> {
|
|
205
|
+
cvc?: T extends 'reference' ? DataElementReference : string;
|
|
206
|
+
expiration_month?: T extends 'reference' ? DataElementReference : number;
|
|
207
|
+
expiration_year?: T extends 'reference' ? DataElementReference : number;
|
|
208
|
+
number?: T extends 'reference' ? DataElementReference : string;
|
|
209
|
+
}
|
|
210
|
+
export interface CardElementPlaceholder {
|
|
211
|
+
cardNumber?: string;
|
|
212
|
+
cardExpirationDate?: string;
|
|
213
|
+
cardSecurityCode?: string;
|
|
214
|
+
}
|
|
215
|
+
export interface CardExpirationDateValue<T extends ElementValueType> {
|
|
216
|
+
month: T extends 'reference' ? DataElementReference : number;
|
|
217
|
+
year: T extends 'reference' ? DataElementReference : number;
|
|
218
|
+
}
|
|
219
|
+
export type CreateCardElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'cardTypes' | 'skipLuhnValidation'> & {
|
|
220
|
+
placeholder?: CardElementPlaceholder;
|
|
221
|
+
value?: CardElementValue<'static'>;
|
|
222
|
+
};
|
|
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'>> & {
|
|
225
|
+
'aria-label'?: string;
|
|
226
|
+
value?: string;
|
|
227
|
+
};
|
|
228
|
+
export type UpdateTextElementOptions = Omit<CreateTextElementOptions, 'targetId' | 'mask' | 'validateOnChange'>;
|
|
229
|
+
export type CreateCardNumberElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'iconPosition' | 'cardTypes' | 'skipLuhnValidation'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
230
|
+
'aria-label'?: string;
|
|
231
|
+
value?: string;
|
|
232
|
+
};
|
|
233
|
+
export type UpdateCardNumberElementOptions = Omit<CreateCardNumberElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
|
|
234
|
+
export type CreateCardExpirationDateElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
235
|
+
'aria-label'?: string;
|
|
236
|
+
value?: CardExpirationDateValue<'static'> | string;
|
|
237
|
+
};
|
|
238
|
+
export type UpdateCardExpirationDateElementOptions = Omit<CreateCardExpirationDateElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
|
|
239
|
+
export type CreateCardVerificationCodeElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'cardBrand'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
240
|
+
'aria-label'?: string;
|
|
241
|
+
value?: string;
|
|
242
|
+
};
|
|
243
|
+
export type UpdateCardVerificationCodeElementOptions = Omit<CreateCardVerificationCodeElementOptions, 'targetId' | 'validateOnChange' | 'enableCopy'>;
|
|
244
|
+
export interface BinDetails {
|
|
245
|
+
cardBrand?: string;
|
|
246
|
+
type?: string;
|
|
247
|
+
prepaid?: boolean;
|
|
248
|
+
cardSegmentType?: string;
|
|
249
|
+
reloadable?: boolean;
|
|
250
|
+
panOrToken?: string;
|
|
251
|
+
accountUpdater?: boolean;
|
|
252
|
+
alm?: boolean;
|
|
253
|
+
domesticOnly?: boolean;
|
|
254
|
+
gamblingBlocked?: boolean;
|
|
255
|
+
level2?: boolean;
|
|
256
|
+
level3?: boolean;
|
|
257
|
+
issuerCurrency?: string;
|
|
258
|
+
comboCard?: string;
|
|
259
|
+
binLength?: number;
|
|
260
|
+
authentication?: unknown;
|
|
261
|
+
cost?: unknown;
|
|
262
|
+
bank?: BinDetailsBank;
|
|
263
|
+
country?: BinDetailsCountry;
|
|
264
|
+
product?: BinDetailsProduct;
|
|
265
|
+
}
|
|
266
|
+
export interface BinDetailsBank {
|
|
267
|
+
name?: string;
|
|
268
|
+
phone?: string;
|
|
269
|
+
url?: string;
|
|
270
|
+
cleanName?: string;
|
|
271
|
+
}
|
|
272
|
+
export interface BinDetailsCountry {
|
|
273
|
+
alpha2?: string;
|
|
274
|
+
name?: string;
|
|
275
|
+
numeric?: string;
|
|
276
|
+
}
|
|
277
|
+
export interface BinDetailsProduct {
|
|
278
|
+
code?: string;
|
|
279
|
+
name?: string;
|
|
280
|
+
}
|
|
281
|
+
export type Primitive = string | number | boolean | null;
|
|
282
|
+
export type TokenType = 'token' | 'card' | 'bank' | 'card_number' | 'us_bank_routing_number' | 'us_bank_account_number' | 'social_security_number';
|
|
283
|
+
export interface Auditable {
|
|
284
|
+
createdBy?: string;
|
|
285
|
+
createdAt?: string;
|
|
286
|
+
modifiedBy?: string;
|
|
287
|
+
modifiedAt?: string;
|
|
288
|
+
}
|
|
289
|
+
export type DataObject<DataType = Primitive> = {
|
|
290
|
+
[member: string]: TokenData<DataType>;
|
|
291
|
+
};
|
|
292
|
+
type DataArray<DataType> = Array<TokenData<DataType>>;
|
|
293
|
+
type TokenData<DataType = Primitive> = Primitive | DataObject<DataType> | DataArray<DataType> | DataType;
|
|
294
|
+
export interface TokenBase<DataType = Primitive> extends Auditable {
|
|
295
|
+
data: TokenData<DataType>;
|
|
296
|
+
type: TokenType;
|
|
297
|
+
}
|
|
298
|
+
export interface ReactResponse {
|
|
299
|
+
tokens: DataObject;
|
|
300
|
+
raw: DataObject;
|
|
301
|
+
}
|
|
302
|
+
export const DATA_CLASSIFICATIONS: readonly ["general", "bank", "pci", "pii"];
|
|
303
|
+
export type DataClassification = (typeof DATA_CLASSIFICATIONS)[number];
|
|
304
|
+
export const DATA_IMPACT_LEVELS: readonly ["low", "moderate", "high"];
|
|
305
|
+
export type DataImpactLevel = (typeof DATA_IMPACT_LEVELS)[number];
|
|
306
|
+
export const DATA_RESTRICTION_POLICIES: readonly ["mask", "redact"];
|
|
307
|
+
export type DataRestrictionPolicy = (typeof DATA_RESTRICTION_POLICIES)[number];
|
|
308
|
+
type MaskObject = {
|
|
309
|
+
[member: string]: TokenMask;
|
|
310
|
+
};
|
|
311
|
+
type MaskArray = Array<TokenMask>;
|
|
312
|
+
type TokenMask = string | null | MaskObject | MaskArray;
|
|
313
|
+
interface TokenEncryptionKey {
|
|
314
|
+
key: string;
|
|
315
|
+
alg: string;
|
|
316
|
+
}
|
|
317
|
+
interface TokenEncryption {
|
|
318
|
+
cek: TokenEncryptionKey;
|
|
319
|
+
kek: TokenEncryptionKey;
|
|
320
|
+
}
|
|
321
|
+
interface TokenPrivacy {
|
|
322
|
+
classification?: DataClassification;
|
|
323
|
+
impactLevel?: DataImpactLevel;
|
|
324
|
+
restrictionPolicy?: DataRestrictionPolicy;
|
|
325
|
+
}
|
|
326
|
+
export interface TokenEnrichments {
|
|
327
|
+
binDetails?: BinDetails;
|
|
328
|
+
}
|
|
329
|
+
export type Token<DataType = Primitive> = TokenBase<DataType> & {
|
|
330
|
+
id: string;
|
|
331
|
+
privacy?: TokenPrivacy;
|
|
332
|
+
containers?: string[];
|
|
333
|
+
encryption?: TokenEncryption;
|
|
334
|
+
searchIndexes?: string[];
|
|
335
|
+
fingerprintExpression?: string;
|
|
336
|
+
mask?: TokenMask;
|
|
337
|
+
expiresAt?: string;
|
|
338
|
+
enrichments?: TokenEnrichments;
|
|
339
|
+
tenantId: string;
|
|
340
|
+
fingerprint?: string;
|
|
341
|
+
metadata?: Record<string, string>;
|
|
342
|
+
};
|
|
343
|
+
export type CreateTokenModel<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
|
|
344
|
+
deduplicateToken?: boolean;
|
|
345
|
+
id?: string;
|
|
346
|
+
};
|
|
347
|
+
export type UpdateTokenModel<DataType = Primitive> = Partial<Pick<Token<DataType>, 'data' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
|
|
348
|
+
privacy: Omit<TokenPrivacy, 'classification'>;
|
|
349
|
+
deduplicateToken: boolean;
|
|
350
|
+
}>;
|
|
351
|
+
export type TokenizeObject<DataType = Primitive> = {
|
|
352
|
+
[key: string]: Primitive | TokenizeObject<DataType> | TokenizeArray<DataType> | DataType;
|
|
353
|
+
};
|
|
354
|
+
export type TokenizeArray<DataType = Primitive> = Array<Primitive | TokenizeObject<DataType> | TokenizeArray<DataType> | DataType>;
|
|
355
|
+
export type TokenizeDataModel<DataType = Primitive> = TokenizeArray<DataType> | TokenizeObject<DataType>;
|
|
356
|
+
export interface Card {
|
|
357
|
+
number: string;
|
|
358
|
+
expirationMonth?: number;
|
|
359
|
+
expirationYear?: number;
|
|
360
|
+
cvc?: string;
|
|
361
|
+
}
|
|
362
|
+
export interface IssuerCountry {
|
|
363
|
+
alpha2: string;
|
|
364
|
+
name: string;
|
|
365
|
+
numeric: string;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Make all properties in T nullable
|
|
369
|
+
*/
|
|
370
|
+
export type Nullable<T> = {
|
|
371
|
+
[P in keyof T]: T[P] | null;
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* Make selected properties in T nullable
|
|
375
|
+
*/
|
|
376
|
+
export type NullableProps<T, K extends keyof T> = T | Nullable<Pick<T, K>>;
|
|
377
|
+
export interface TokenIntentCardDetails {
|
|
378
|
+
type: 'card';
|
|
379
|
+
card: {
|
|
380
|
+
bin: string;
|
|
381
|
+
last4: string;
|
|
382
|
+
brand: string;
|
|
383
|
+
funding: string;
|
|
384
|
+
expirationMonth: number;
|
|
385
|
+
expirationYear: number;
|
|
386
|
+
issuerCountry?: IssuerCountry;
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
interface TokenIntentBankDetails {
|
|
390
|
+
type: 'bank';
|
|
391
|
+
bank: {
|
|
392
|
+
routingNumber: string;
|
|
393
|
+
accountNumberLast4: string;
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
type TokenTypesForTokenIntents = Exclude<TokenType, 'token' | 'card' | 'bank'>;
|
|
397
|
+
type TokenTypeMap = {
|
|
398
|
+
[K in TokenTypesForTokenIntents]: {
|
|
399
|
+
type: K;
|
|
400
|
+
} & Record<K, Record<string, unknown>>;
|
|
401
|
+
};
|
|
402
|
+
export type TokenIntent<DataType = DataObject> = (TokenBase<DataType> & Omit<Auditable, 'modifiedAt' | 'modifiedBy'> & {
|
|
403
|
+
id: string;
|
|
404
|
+
tenantId: string;
|
|
405
|
+
expiresAt: string;
|
|
406
|
+
fingerprint?: string;
|
|
407
|
+
}) & (TokenTypeMap[TokenTypesForTokenIntents] | TokenIntentCardDetails | TokenIntentBankDetails | {
|
|
408
|
+
type: 'token';
|
|
409
|
+
});
|
|
410
|
+
export type CreateTokenIntentModel<DataType = DataObject> = Pick<TokenIntent<DataType>, 'type' | 'data'>;
|
|
411
|
+
interface RequestOptions {
|
|
412
|
+
apiKey?: string;
|
|
413
|
+
correlationId?: string;
|
|
414
|
+
idempotencyKey?: string;
|
|
415
|
+
}
|
|
416
|
+
type Create<T, C> = {
|
|
417
|
+
create(model: C, options?: RequestOptions): Promise<T>;
|
|
418
|
+
};
|
|
419
|
+
type Retrieve<T> = {
|
|
420
|
+
retrieve(id: string, options?: RequestOptions): Promise<T>;
|
|
421
|
+
};
|
|
422
|
+
type Update<T, U> = {
|
|
423
|
+
update(id: string, model: U, options?: RequestOptions): Promise<T>;
|
|
424
|
+
};
|
|
425
|
+
export type TokenizeData = TokenizeDataModel<ElementValue>;
|
|
426
|
+
export interface Tokenize {
|
|
427
|
+
tokenize(tokens: TokenizeData, options?: RequestOptions): Promise<TokenizeDataModel>;
|
|
428
|
+
}
|
|
429
|
+
export type CreateToken = CreateTokenModel<ElementValue>;
|
|
430
|
+
export type UpdateToken = UpdateTokenModel<ElementValue>;
|
|
431
|
+
export type Tokens = Create<Token, CreateToken> & Retrieve<Token<any>> & Update<Token, UpdateToken>;
|
|
432
|
+
type BasisTheoryProxyHeaders = {
|
|
433
|
+
[key: string]: string;
|
|
434
|
+
'BT-PROXY-URL': string;
|
|
435
|
+
'BT-PROXY-KEY': string;
|
|
436
|
+
};
|
|
437
|
+
type ProxyHeaders = Partial<BasisTheoryProxyHeaders>;
|
|
438
|
+
type BasisTheoryQueryParams = {
|
|
439
|
+
[key: string]: string;
|
|
440
|
+
'bt-proxy-key': string;
|
|
441
|
+
};
|
|
442
|
+
type ProxyQuery = Partial<BasisTheoryQueryParams>;
|
|
443
|
+
export interface ProxyRequestOptions extends RequestOptions {
|
|
444
|
+
includeResponseHeaders?: boolean;
|
|
445
|
+
path?: string;
|
|
446
|
+
query?: ProxyQuery;
|
|
447
|
+
headers?: ProxyHeaders;
|
|
448
|
+
body?: unknown;
|
|
449
|
+
}
|
|
450
|
+
export interface Proxy {
|
|
451
|
+
get(options?: ProxyRequestOptions): Promise<unknown>;
|
|
452
|
+
post(options?: ProxyRequestOptions): Promise<unknown>;
|
|
453
|
+
patch(options?: ProxyRequestOptions): Promise<unknown>;
|
|
454
|
+
put(options?: ProxyRequestOptions): Promise<unknown>;
|
|
455
|
+
delete(options?: ProxyRequestOptions): Promise<unknown>;
|
|
456
|
+
}
|
|
457
|
+
export type CreateTokenIntent = CreateTokenIntentModel<ElementValue>;
|
|
458
|
+
export type TokenIntents = Create<TokenIntent, CreateTokenIntent>;
|
|
459
|
+
type CreateSessionResponse = {
|
|
460
|
+
sessionKey: string;
|
|
461
|
+
nonce: string;
|
|
462
|
+
expiresAt: string;
|
|
463
|
+
_debug?: Record<string, unknown>;
|
|
464
|
+
};
|
|
465
|
+
interface Sessions {
|
|
466
|
+
create(options?: RequestOptions): Promise<CreateSessionResponse>;
|
|
467
|
+
}
|
|
468
|
+
export interface BaseElement<UpdateOptions, ElementEvents> {
|
|
469
|
+
readonly mounted: boolean;
|
|
470
|
+
readonly metadata: ElementMetadata;
|
|
471
|
+
mount(selector: string): Promise<void>;
|
|
472
|
+
mount(element: Element): Promise<void>;
|
|
473
|
+
update(options: UpdateOptions): Promise<void>;
|
|
474
|
+
clear(): void;
|
|
475
|
+
focus(): void;
|
|
476
|
+
blur(): void;
|
|
477
|
+
unmount(): void;
|
|
478
|
+
on<T extends EventType>(eventType: T, listener: ElementEventListener<ElementEvents, T>): Subscription;
|
|
479
|
+
}
|
|
480
|
+
export type ICardElement = BaseElement<UpdateCardElementOptions, CardElementEvents> & {
|
|
481
|
+
readonly cardMetadata?: CardMetadata;
|
|
482
|
+
setValue(value: CardElementValue<'reference'>): void;
|
|
483
|
+
validate(): void;
|
|
484
|
+
};
|
|
485
|
+
export type ITextElement = BaseElement<UpdateTextElementOptions, TextElementEvents> & {
|
|
486
|
+
setValueRef(value: ITextElement): void;
|
|
487
|
+
setValue(value: DataElementReference): void;
|
|
488
|
+
};
|
|
489
|
+
export type ICardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents> & {
|
|
490
|
+
readonly cardMetadata?: CardMetadata;
|
|
491
|
+
setValueRef(value: ICardNumberElement): void;
|
|
492
|
+
setValue(value: DataElementReference): void;
|
|
493
|
+
};
|
|
494
|
+
export type ICardExpirationDateElement = BaseElement<UpdateCardExpirationDateElementOptions, CardExpirationDateElementEvents> & {
|
|
495
|
+
setValueRef(value: ICardExpirationDateElement): void;
|
|
496
|
+
setValue(value: CardExpirationDateValue<'reference'>): void;
|
|
497
|
+
month(): ElementWrapper<ICardExpirationDateElement>;
|
|
498
|
+
year(): ElementWrapper<ICardExpirationDateElement>;
|
|
499
|
+
format(dateFormat: string): ElementWrapper<ICardExpirationDateElement>;
|
|
500
|
+
};
|
|
501
|
+
export type ICardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents> & {
|
|
502
|
+
setValueRef(value: ICardVerificationCodeElement): void;
|
|
503
|
+
setValue(value: DataElementReference): void;
|
|
504
|
+
};
|
|
505
|
+
export type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
|
|
506
|
+
element: T;
|
|
507
|
+
method?: string;
|
|
508
|
+
formattingOptions?: {
|
|
509
|
+
format: string;
|
|
510
|
+
};
|
|
511
|
+
};
|
|
512
|
+
export type ElementValue = ITextElement | ICardElement | ICardNumberElement | ICardExpirationDateElement | ICardVerificationCodeElement | ElementWrapper;
|
|
513
|
+
export interface BasisTheoryElements {
|
|
514
|
+
tokens: Tokens;
|
|
515
|
+
proxy: Proxy;
|
|
516
|
+
sessions: Sessions;
|
|
517
|
+
tokenIntents: TokenIntents;
|
|
518
|
+
tokenize: Tokenize['tokenize'];
|
|
519
|
+
client: HttpClient;
|
|
520
|
+
createElement(type: 'card', options?: CreateCardElementOptions): ICardElement;
|
|
521
|
+
createElement(type: 'text', options: CreateTextElementOptions): ITextElement;
|
|
522
|
+
createElement(type: 'cardNumber', options: CreateCardNumberElementOptions): ICardNumberElement;
|
|
523
|
+
createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): ICardExpirationDateElement;
|
|
524
|
+
createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): ICardVerificationCodeElement;
|
|
525
|
+
}
|
|
526
|
+
export interface BasisTheoryElementsInternal extends BasisTheoryElements {
|
|
527
|
+
init: (apiKey: string | undefined, elementsBaseUrl: string, elementsUseNgApi: boolean | undefined, elementsUseSameOriginApi: boolean | undefined, disableTelemetry: boolean | undefined, debug: boolean | undefined) => Promise<BasisTheoryElements>;
|
|
528
|
+
hasElement: (payload: unknown) => boolean;
|
|
529
|
+
}
|
|
530
|
+
declare global {
|
|
531
|
+
interface Window {
|
|
532
|
+
BasisTheoryElements?: BasisTheoryElementsInternal;
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
export interface BasisTheoryInitOptions {
|
|
536
|
+
_devMode?: boolean;
|
|
537
|
+
disableTelemetry?: boolean;
|
|
538
|
+
useSameOriginApi?: boolean;
|
|
539
|
+
debug?: boolean;
|
|
540
|
+
}
|
|
541
|
+
export const basistheory: (apiKey: string, options?: BasisTheoryInitOptions) => Promise<BasisTheoryElements | undefined>;
|
|
2
542
|
declare global {
|
|
3
543
|
interface Window {
|
|
4
544
|
basistheory?: typeof basistheory;
|
|
5
545
|
}
|
|
6
546
|
}
|
|
7
|
-
export * from './BasisTheory';
|
|
8
|
-
export * from './types';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@basis-theory/web-elements",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.4",
|
|
4
4
|
"repository": "https://github.com/basis-theory/web-elements",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -16,10 +16,9 @@
|
|
|
16
16
|
],
|
|
17
17
|
"scripts": {
|
|
18
18
|
"prebuild": "TARGET_DIR=../../web-elements/src node ../scripts/web-elements/write-version-file.js",
|
|
19
|
-
"build:dev": "yarn clean && parcel build &&
|
|
20
|
-
"build": "node ../scripts/web-elements/prepare.js && parcel build --no-cache && yarn
|
|
19
|
+
"build:dev": "yarn clean && parcel build && npx size-limit && yarn generate-sri",
|
|
20
|
+
"build": "node ../scripts/web-elements/prepare.js && parcel build --no-cache && yarn generate-sri",
|
|
21
21
|
"clean": "rimraf dist .parcel-cache",
|
|
22
|
-
"generateTypes": "tsc --emitDeclarationOnly",
|
|
23
22
|
"generate-sri": "node ../scripts/web-elements/generate-sri.js",
|
|
24
23
|
"lint-staged": "lint-staged",
|
|
25
24
|
"lint:fix": "eslint --fix",
|
|
@@ -73,11 +72,10 @@
|
|
|
73
72
|
}
|
|
74
73
|
],
|
|
75
74
|
"devDependencies": {
|
|
76
|
-
"@parcel/packager-ts": "2.
|
|
77
|
-
"@parcel/transformer-typescript-types": "2.
|
|
75
|
+
"@parcel/packager-ts": "2.14.2",
|
|
76
|
+
"@parcel/transformer-typescript-types": "2.14.2",
|
|
78
77
|
"@size-limit/preset-small-lib": "^11.1.6",
|
|
79
|
-
"parcel": "^2.
|
|
80
|
-
"ts-jest": "^29.2.5"
|
|
81
|
-
"typescript": "^5.7.2"
|
|
78
|
+
"parcel": "^2.14.2",
|
|
79
|
+
"ts-jest": "^29.2.5"
|
|
82
80
|
}
|
|
83
81
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BasisTheoryElements } from './types/elements';
|
|
2
|
-
interface BasisTheoryInitOptions {
|
|
3
|
-
_devMode?: boolean;
|
|
4
|
-
disableTelemetry?: boolean;
|
|
5
|
-
useSameOriginApi?: boolean;
|
|
6
|
-
debug?: boolean;
|
|
7
|
-
}
|
|
8
|
-
declare const basistheory: (apiKey: string, options?: BasisTheoryInitOptions) => Promise<BasisTheoryElements | undefined>;
|
|
9
|
-
export { basistheory, BasisTheoryInitOptions };
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { FieldError } from '../types/elements';
|
|
2
|
-
export declare class BasisTheoryValidationError<Details = Record<string, unknown>> extends Error {
|
|
3
|
-
readonly details: Details;
|
|
4
|
-
/**
|
|
5
|
-
* @deprecated use {@link details}
|
|
6
|
-
*/
|
|
7
|
-
readonly validation?: FieldError[] | undefined;
|
|
8
|
-
constructor(message: string, details: Details,
|
|
9
|
-
/**
|
|
10
|
-
* @deprecated use {@link details}
|
|
11
|
-
*/
|
|
12
|
-
validation?: FieldError[] | undefined);
|
|
13
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const logger: {
|
|
2
|
-
setTelemetryEnabled: (enabled: boolean) => void;
|
|
3
|
-
log: {
|
|
4
|
-
error: (message: string, attributes?: {}) => Promise<void>;
|
|
5
|
-
info: (message: string, attributes?: {}) => Promise<void>;
|
|
6
|
-
warn: (message: string, attributes?: {}) => Promise<void>;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
declare const ELEMENTS_INIT_ERROR_MESSAGE = "BasisTheory Elements was not properly initialized.";
|
|
2
|
-
declare const ELEMENTS_NON_DOM_ERROR_MESSAGE = "Tried to load BasisTheoryElements in a non-DOM environment.";
|
|
3
|
-
declare const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = "Basis Theory Elements did not load properly. Check network tab for more details.";
|
|
4
|
-
declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "Unable to load the Elements script. This may be due to network restrictions or browser extensions like ad blockers interfering with script loading. Check browser settings or network connection and try again.";
|
|
5
|
-
declare const ELEMENTS_SCRIPT_FAILED_TO_DELIVER = "Failed to deliver Elements script from Basis Theory. Check your network connection and try again or contact support@basistheory.com";
|
|
6
|
-
declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
|
|
7
|
-
declare const CARD_ICON_POSITIONS: readonly ["left", "right", "none"];
|
|
8
|
-
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"];
|
|
9
|
-
export { AUTOCOMPLETE_VALUES, CARD_BRANDS, CARD_ICON_POSITIONS, ELEMENTS_INIT_ERROR_MESSAGE, ELEMENTS_NON_DOM_ERROR_MESSAGE, ELEMENTS_SCRIPT_FAILED_TO_DELIVER, ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE, ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE, };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const getOrCreateScriptElement: (url: string) => HTMLScriptElement;
|