@basis-theory/basis-theory-js 1.29.0 → 1.32.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/BasisTheory.d.ts +3 -1
- package/elements/constants.d.ts +2 -1
- package/elements/constants.js +4 -2
- package/package.json +1 -1
- package/tokens/BasisTheoryTokens.d.ts +1 -1
- package/types/elements/elements.d.ts +8 -5
- package/types/elements/events.d.ts +3 -1
- package/types/elements/options.d.ts +12 -2
- package/types/elements/options.js +1 -1
- package/types/elements/shared.d.ts +2 -1
- package/types/models/tokens.d.ts +2 -1
package/BasisTheory.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AtomicBanks as ElementsAtomicBanks, AtomicCards as ElementsAtomicCards, BasisTheoryElements, CardElement, CardExpirationDateElement, CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from '@/types/elements';
|
|
1
|
+
import type { AtomicBanks as ElementsAtomicBanks, AtomicCards as ElementsAtomicCards, BasisTheoryElements, CardElement, CardNumberElement, CardExpirationDateElement, CardVerificationCodeElement, CreateCardElementOptions, CreateCardNumberElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from '@/types/elements';
|
|
2
2
|
import type { TokenizeData } from '@/types/models';
|
|
3
3
|
import type { Applications, AtomicBanks, AtomicCards, BasisTheory as IBasisTheory, BasisTheoryInit, Logs, Permissions, ReactorFormulas, Reactors, RequestOptions, Tenants, Tokens, BasisTheoryInitOptions, BasisTheoryInitOptionsWithElements, BasisTheoryInitOptionsWithoutElements } from '@/types/sdk';
|
|
4
4
|
export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, BasisTheoryElements {
|
|
@@ -19,7 +19,9 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
|
|
|
19
19
|
init(apiKey: string, options: BasisTheoryInitOptionsWithElements): Promise<IBasisTheory & BasisTheoryElements>;
|
|
20
20
|
createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
|
|
21
21
|
createElement(type: 'text', options: CreateTextElementOptions): TextElement;
|
|
22
|
+
createElement(type: 'cardNumber', options: CreateCardNumberElementOptions): CardNumberElement;
|
|
22
23
|
createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
|
|
24
|
+
createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
|
|
23
25
|
tokenize(tokens: TokenizeData & ElementsTokenizeData, options?: RequestOptions): Promise<TokenizeData>;
|
|
24
26
|
private loadElements;
|
|
25
27
|
get initOptions(): Required<BasisTheoryInitOptions>;
|
package/elements/constants.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ declare const ELEMENTS_INIT_ERROR_MESSAGE = "BasisTheory Elements was not proper
|
|
|
2
2
|
declare const ELEMENTS_NOM_DOM_ERROR_MESSAGE = "Tried to load BasisTheoryElements in a non-DOM environment.";
|
|
3
3
|
declare const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = "BasisTheoryElements did not load properly.";
|
|
4
4
|
declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "There was an unknown error when loading BasisTheoryElements";
|
|
5
|
-
|
|
5
|
+
declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
|
|
6
|
+
export { ELEMENTS_INIT_ERROR_MESSAGE, ELEMENTS_NOM_DOM_ERROR_MESSAGE, ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE, ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE, CARD_BRANDS, };
|
package/elements/constants.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = exports.ELEMENTS_NOM_DOM_ERROR_MESSAGE = exports.ELEMENTS_INIT_ERROR_MESSAGE = void 0;
|
|
6
|
+
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = exports.ELEMENTS_NOM_DOM_ERROR_MESSAGE = exports.ELEMENTS_INIT_ERROR_MESSAGE = exports.CARD_BRANDS = void 0;
|
|
7
7
|
const ELEMENTS_INIT_ERROR_MESSAGE = 'BasisTheory Elements was not properly initialized.';
|
|
8
8
|
exports.ELEMENTS_INIT_ERROR_MESSAGE = ELEMENTS_INIT_ERROR_MESSAGE;
|
|
9
9
|
const ELEMENTS_NOM_DOM_ERROR_MESSAGE = 'Tried to load BasisTheoryElements in a non-DOM environment.';
|
|
@@ -11,4 +11,6 @@ exports.ELEMENTS_NOM_DOM_ERROR_MESSAGE = ELEMENTS_NOM_DOM_ERROR_MESSAGE;
|
|
|
11
11
|
const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = 'BasisTheoryElements did not load properly.';
|
|
12
12
|
exports.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE;
|
|
13
13
|
const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = 'There was an unknown error when loading BasisTheoryElements';
|
|
14
|
-
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE;
|
|
14
|
+
exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE;
|
|
15
|
+
const CARD_BRANDS = ['visa', 'mastercard', 'american-express', 'discover', 'diners-club', 'jcb', 'unionpay', 'maestro', 'elo', 'hiper', 'hipercard', 'mir', 'unknown'];
|
|
16
|
+
exports.CARD_BRANDS = CARD_BRANDS;
|
package/package.json
CHANGED
|
@@ -11,5 +11,5 @@ export declare const BasisTheoryTokens: {
|
|
|
11
11
|
search(searchRequest: SearchTokensRequest, options?: RequestOptions | undefined): Promise<PaginatedList<Token>>;
|
|
12
12
|
readonly client: import("axios").AxiosInstance;
|
|
13
13
|
};
|
|
14
|
-
} & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token<import("../types/models/shared").Primitive>, Pick<Token<import("../types/models/shared").Primitive>, "type" | "data" | "privacy" | "metadata" | "encryption">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Token<import("../types/models/shared").Primitive>, ListTokensQuery>);
|
|
14
|
+
} & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token<import("../types/models/shared").Primitive>, Pick<Token<import("../types/models/shared").Primitive>, "type" | "data" | "privacy" | "metadata" | "encryption" | "searchIndexes">>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Token<import("../types/models/shared").Primitive>, ListTokensQuery>);
|
|
15
15
|
export declare type BasisTheoryTokens = InstanceType<typeof BasisTheoryTokens>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { ElementEventListener, EventType, Subscription, TextElementEvents, CardElementEvents } from './events';
|
|
2
|
-
import {
|
|
3
|
-
import type { CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateTextElementOptions, UpdateCardElementOptions, UpdateCardExpirationDateElementOptions, UpdateTextElementOptions } from './options';
|
|
1
|
+
import type { ElementEventListener, EventType, Subscription, TextElementEvents, CardElementEvents, CardNumberElementEvents, CardExpirationDateElementEvents, CardVerificationCodeElementEvents } from './events';
|
|
2
|
+
import type { CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, UpdateCardElementOptions, CreateCardNumberElementOptions, UpdateCardNumberElementOptions, UpdateCardExpirationDateElementOptions, UpdateCardVerificationCodeElementOptions, UpdateTextElementOptions } from './options';
|
|
4
3
|
import type { AtomicBanks, AtomicCards, Tokenize, Tokens } from './services';
|
|
5
4
|
interface BaseElement<UpdateOptions, ElementEvents> {
|
|
6
5
|
readonly mounted: boolean;
|
|
@@ -12,15 +11,17 @@ interface BaseElement<UpdateOptions, ElementEvents> {
|
|
|
12
11
|
}
|
|
13
12
|
declare type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents>;
|
|
14
13
|
declare type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents>;
|
|
14
|
+
declare type CardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents>;
|
|
15
15
|
declare type CardExpirationDateElement = BaseElement<UpdateCardExpirationDateElementOptions, CardExpirationDateElementEvents> & {
|
|
16
16
|
month(): ElementWrapper<CardExpirationDateElement>;
|
|
17
17
|
year(): ElementWrapper<CardExpirationDateElement>;
|
|
18
18
|
};
|
|
19
|
+
declare type CardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents>;
|
|
19
20
|
declare type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
|
|
20
21
|
element: T;
|
|
21
22
|
method?: string;
|
|
22
23
|
};
|
|
23
|
-
declare type ElementValue = TextElement | CardElement | CardExpirationDateElement | ElementWrapper;
|
|
24
|
+
declare type ElementValue = TextElement | CardElement | CardNumberElement | CardExpirationDateElement | CardVerificationCodeElement | ElementWrapper;
|
|
24
25
|
interface BasisTheoryElements extends Tokenize {
|
|
25
26
|
/**
|
|
26
27
|
* @deprecated use {@link tokens} or {@link tokenize}
|
|
@@ -33,7 +34,9 @@ interface BasisTheoryElements extends Tokenize {
|
|
|
33
34
|
tokens: Tokens;
|
|
34
35
|
createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
|
|
35
36
|
createElement(type: 'text', options: CreateTextElementOptions): TextElement;
|
|
37
|
+
createElement(type: 'cardNumber', options: CreateCardNumberElementOptions): CardNumberElement;
|
|
36
38
|
createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
|
|
39
|
+
createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
|
|
37
40
|
}
|
|
38
41
|
interface BasisTheoryElementsInternal extends BasisTheoryElements {
|
|
39
42
|
init: (apiKey: string, elementsBaseUrl: string) => Promise<BasisTheoryElements>;
|
|
@@ -44,4 +47,4 @@ declare global {
|
|
|
44
47
|
BasisTheoryElements?: BasisTheoryElementsInternal;
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
|
-
export type { BaseElement, CardElement, TextElement, CardExpirationDateElement, ElementWrapper, ElementValue, BasisTheoryElements, BasisTheoryElementsInternal, };
|
|
50
|
+
export type { BaseElement, CardElement, TextElement, CardNumberElement, CardExpirationDateElement, CardVerificationCodeElement, ElementWrapper, ElementValue, BasisTheoryElements, BasisTheoryElementsInternal, };
|
|
@@ -20,7 +20,9 @@ declare type InputKeydownEvent = BaseEvent<'keydown'> & Targeted & {
|
|
|
20
20
|
declare type BaseElementEvents = ReadyEvent | InputFocusEvent | InputBlurEvent | InputKeydownEvent;
|
|
21
21
|
declare type TextElementEvents = BaseElementEvents | ChangeEvent;
|
|
22
22
|
declare type CardElementEvents = BaseElementEvents | CardChangeEvent;
|
|
23
|
+
declare type CardNumberElementEvents = BaseElementEvents | CardChangeEvent;
|
|
23
24
|
declare type CardExpirationDateElementEvents = BaseElementEvents | ChangeEvent;
|
|
25
|
+
declare type CardVerificationCodeElementEvents = BaseElementEvents | ChangeEvent;
|
|
24
26
|
/**
|
|
25
27
|
* Utility type that helps find a Union type based on a `type` property
|
|
26
28
|
*/
|
|
@@ -31,4 +33,4 @@ declare type ElementEventListener<Events, Type> = (event: FindByType<Events, Typ
|
|
|
31
33
|
interface Subscription {
|
|
32
34
|
unsubscribe(): void;
|
|
33
35
|
}
|
|
34
|
-
export type { EventType, BaseEvent, ReadyEvent, ChangeEvent, CardChangeEvent, InputFocusEvent, InputBlurEvent, InputKeydownEvent, BaseElementEvents, TextElementEvents, CardElementEvents, CardExpirationDateElementEvents, ElementEventListener, Subscription, };
|
|
36
|
+
export type { EventType, BaseEvent, ReadyEvent, ChangeEvent, CardChangeEvent, InputFocusEvent, InputBlurEvent, InputKeydownEvent, BaseElementEvents, TextElementEvents, CardElementEvents, CardNumberElementEvents, CardExpirationDateElementEvents, CardVerificationCodeElementEvents, ElementEventListener, Subscription, };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ElementStyle } from './styles';
|
|
2
|
-
declare const ELEMENTS_TYPES: readonly ["card", "text", "cardExpirationDate"];
|
|
2
|
+
declare const ELEMENTS_TYPES: readonly ["card", "text", "cardNumber", "cardExpirationDate", "cardVerificationCode"];
|
|
3
3
|
declare type ElementType = typeof ELEMENTS_TYPES[number];
|
|
4
4
|
interface ElementInternalOptions {
|
|
5
5
|
apiKey: string;
|
|
@@ -16,6 +16,8 @@ interface SanitizedElementOptions {
|
|
|
16
16
|
transform?: [RegExp, string] | null;
|
|
17
17
|
ariaDescription?: string;
|
|
18
18
|
ariaLabel?: string;
|
|
19
|
+
iconPosition?: 'left' | 'right' | 'none';
|
|
20
|
+
cardBrand?: string;
|
|
19
21
|
}
|
|
20
22
|
declare type ElementOptions = ElementInternalOptions & SanitizedElementOptions;
|
|
21
23
|
declare type Transform = RegExp | [RegExp, string?] | null;
|
|
@@ -29,9 +31,17 @@ declare type CreateTextElementOptions = CustomizableElementOptions & Pick<Elemen
|
|
|
29
31
|
'aria-label'?: string;
|
|
30
32
|
};
|
|
31
33
|
declare type UpdateTextElementOptions = Omit<CreateTextElementOptions, 'targetId' | 'mask'>;
|
|
34
|
+
declare type CreateCardNumberElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'iconPosition'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
35
|
+
'aria-label'?: string;
|
|
36
|
+
};
|
|
37
|
+
declare type UpdateCardNumberElementOptions = Omit<CreateCardNumberElementOptions, 'targetId'>;
|
|
32
38
|
declare type CreateCardExpirationDateElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
33
39
|
'aria-label'?: string;
|
|
34
40
|
};
|
|
35
41
|
declare type UpdateCardExpirationDateElementOptions = Omit<CreateCardExpirationDateElementOptions, 'targetId'>;
|
|
36
|
-
|
|
42
|
+
declare type CreateCardVerificationCodeElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'cardBrand'> & Required<Pick<ElementOptions, 'targetId'>> & {
|
|
43
|
+
'aria-label'?: string;
|
|
44
|
+
};
|
|
45
|
+
declare type UpdateCardVerificationCodeElementOptions = Omit<CreateCardVerificationCodeElementOptions, 'targetId'>;
|
|
46
|
+
export type { ElementInternalOptions, ElementType, ElementOptions, SanitizedElementOptions, Transform, CustomizableElementOptions, CreateCardElementOptions, UpdateCardElementOptions, CreateTextElementOptions, UpdateTextElementOptions, CreateCardNumberElementOptions, UpdateCardNumberElementOptions, CreateCardExpirationDateElementOptions, UpdateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, UpdateCardVerificationCodeElementOptions, };
|
|
37
47
|
export { ELEMENTS_TYPES };
|
|
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ELEMENTS_TYPES = void 0;
|
|
7
|
-
const ELEMENTS_TYPES = ['card', 'text', 'cardExpirationDate'];
|
|
7
|
+
const ELEMENTS_TYPES = ['card', 'text', 'cardNumber', 'cardExpirationDate', 'cardVerificationCode'];
|
|
8
8
|
exports.ELEMENTS_TYPES = ELEMENTS_TYPES;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CARD_BRANDS } from '@/elements/constants';
|
|
1
2
|
declare type FieldErrorType = 'incomplete' | 'invalid';
|
|
2
3
|
declare type ConfigErrorType = 'missing-configuration' | 'missing-permission' | 'invalid-configuration';
|
|
3
4
|
interface ConfigError {
|
|
@@ -18,5 +19,5 @@ interface PropertyError {
|
|
|
18
19
|
/**
|
|
19
20
|
* Card brands type
|
|
20
21
|
*/
|
|
21
|
-
declare type Brand =
|
|
22
|
+
declare type Brand = typeof CARD_BRANDS[number];
|
|
22
23
|
export type { FieldErrorType, ConfigErrorType, ConfigError, Targeted, ListenableKey, FieldError, PropertyError, Brand, };
|
package/types/models/tokens.d.ts
CHANGED
|
@@ -27,7 +27,8 @@ interface Token<DataType = Primitive> extends TokenBase {
|
|
|
27
27
|
data: TokenData<DataType>;
|
|
28
28
|
privacy?: TokenPrivacy;
|
|
29
29
|
encryption?: TokenEncryption;
|
|
30
|
+
searchIndexes?: string[];
|
|
30
31
|
}
|
|
31
|
-
declare type CreateToken<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'metadata' | 'encryption'>;
|
|
32
|
+
declare type CreateToken<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'metadata' | 'encryption' | 'searchIndexes'>;
|
|
32
33
|
export type { Token, CreateToken, DataArray, DataObject, TokenData, DataClassification, DataImpactLevel, DataRestrictionPolicy, };
|
|
33
34
|
export { DATA_CLASSIFICATIONS, DATA_IMPACT_LEVELS, DATA_RESTRICTION_POLICIES };
|