@basis-theory/basis-theory-js 1.53.1 → 1.55.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 CHANGED
@@ -14,8 +14,8 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
14
14
  private _reactors?;
15
15
  private _permissions?;
16
16
  private _proxies?;
17
- init(apiKey: string, options?: BasisTheoryInitOptionsWithoutElements): Promise<IBasisTheory>;
18
- init(apiKey: string, options: BasisTheoryInitOptionsWithElements): Promise<IBasisTheory & BasisTheoryElements>;
17
+ init(apiKey: string | undefined, options?: BasisTheoryInitOptionsWithoutElements): Promise<IBasisTheory>;
18
+ init(apiKey: string | undefined, options: BasisTheoryInitOptionsWithElements): Promise<IBasisTheory & BasisTheoryElements>;
19
19
  createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
20
20
  createElement(type: 'text', options: CreateTextElementOptions): TextElement;
21
21
  createElement(type: 'cardNumber', options: CreateCardNumberElementOptions): CardNumberElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-js",
3
- "version": "1.53.1",
3
+ "version": "1.55.0",
4
4
  "repository": "https://github.com/Basis-Theory/basis-theory-js",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -3,7 +3,7 @@ import type { Token, CreateToken, UpdateToken } from '../types/models';
3
3
  import type { PaginatedList, RequestOptions, ListTokensQuery, SearchTokensRequest } from '../types/sdk';
4
4
  export declare const BasisTheoryTokens: {
5
5
  new (options: BasisTheoryServiceOptions): {
6
- retrieve(id: string, options?: RequestOptions): Promise<Token>;
6
+ retrieve(id: string, options?: RequestOptions): Promise<Token<any>>;
7
7
  update(id: string, model: UpdateToken, options?: RequestOptions): Promise<Token>;
8
8
  createAssociation(parentId: string, childId: string, options?: RequestOptions | undefined): Promise<void>;
9
9
  deleteAssociation(parentId: string, childId: string, options?: RequestOptions | undefined): Promise<void>;
@@ -23,7 +23,9 @@ const BasisTheoryTokens = new _CrudBuilder.CrudBuilder(class BasisTheoryTokens e
23
23
  super(_options);
24
24
  }
25
25
 
26
- retrieve(id, options = {}) {
26
+ retrieve(id, options = {} // avoid casting when accessing token data props
27
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
28
+ ) {
27
29
  const url = `/${id}`;
28
30
  return this.client.get(url, (0, _common.createRequestConfig)(options)).then(_utils.dataExtractor);
29
31
  }
@@ -1,6 +1,7 @@
1
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';
2
+ import type { CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, UpdateCardElementOptions, CreateCardNumberElementOptions, UpdateCardNumberElementOptions, UpdateCardExpirationDateElementOptions, UpdateCardVerificationCodeElementOptions, UpdateTextElementOptions, CardElementValue, CardExpirationDateValue } from './options';
3
3
  import type { Tokenize, Tokens } from './services';
4
+ import { DataElementReference } from './shared';
4
5
  interface BaseElement<UpdateOptions, ElementEvents> {
5
6
  readonly mounted: boolean;
6
7
  mount(selector: string): Promise<void>;
@@ -11,14 +12,23 @@ interface BaseElement<UpdateOptions, ElementEvents> {
11
12
  unmount(): void;
12
13
  on<T extends EventType>(eventType: T, listener: ElementEventListener<ElementEvents, T>): Subscription;
13
14
  }
14
- declare type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents>;
15
- declare type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents>;
16
- declare type CardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents>;
15
+ declare type CardElement = BaseElement<UpdateCardElementOptions, CardElementEvents> & {
16
+ setValue(value: CardElementValue<'reference'>): void;
17
+ };
18
+ declare type TextElement = BaseElement<UpdateTextElementOptions, TextElementEvents> & {
19
+ setValue(value: DataElementReference): void;
20
+ };
21
+ declare type CardNumberElement = BaseElement<UpdateCardNumberElementOptions, CardNumberElementEvents> & {
22
+ setValue(value: DataElementReference): void;
23
+ };
17
24
  declare type CardExpirationDateElement = BaseElement<UpdateCardExpirationDateElementOptions, CardExpirationDateElementEvents> & {
18
25
  month(): ElementWrapper<CardExpirationDateElement>;
19
26
  year(): ElementWrapper<CardExpirationDateElement>;
27
+ setValue(value: CardExpirationDateValue<'reference'>): void;
28
+ };
29
+ declare type CardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents> & {
30
+ setValue(value: DataElementReference): void;
20
31
  };
21
- declare type CardVerificationCodeElement = BaseElement<UpdateCardVerificationCodeElementOptions, CardVerificationCodeElementEvents>;
22
32
  declare type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
23
33
  element: T;
24
34
  method?: string;
@@ -34,13 +34,13 @@ declare type CustomizableElementOptions = Pick<ElementOptions, 'style' | 'disabl
34
34
  declare type ElementValueType = 'static' | 'reference';
35
35
  interface CardElementValue<T extends ElementValueType> {
36
36
  number?: T extends 'reference' ? DataElementReference : string;
37
- expiration_month?: T extends 'reference' ? DataElementReference : string;
38
- expiration_year?: T extends 'reference' ? DataElementReference : string;
37
+ expiration_month?: T extends 'reference' ? DataElementReference : number;
38
+ expiration_year?: T extends 'reference' ? DataElementReference : number;
39
39
  cvc?: T extends 'reference' ? DataElementReference : string;
40
40
  }
41
41
  interface CardExpirationDateValue<T extends ElementValueType> {
42
- month: T extends 'reference' ? DataElementReference : string;
43
- year: T extends 'reference' ? DataElementReference : string;
42
+ month: T extends 'reference' ? DataElementReference : number;
43
+ year: T extends 'reference' ? DataElementReference : number;
44
44
  }
45
45
  declare type CreateCardElementOptions = CustomizableElementOptions & {
46
46
  value?: CardElementValue<'static'>;
@@ -58,7 +58,7 @@ declare type CreateCardNumberElementOptions = CustomizableElementOptions & Pick<
58
58
  declare type UpdateCardNumberElementOptions = Omit<CreateCardNumberElementOptions, 'targetId'>;
59
59
  declare type CreateCardExpirationDateElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder'> & Required<Pick<ElementOptions, 'targetId'>> & {
60
60
  'aria-label'?: string;
61
- value?: CardExpirationDateValue<'static'>;
61
+ value?: CardExpirationDateValue<'static'> | string;
62
62
  };
63
63
  declare type UpdateCardExpirationDateElementOptions = Omit<CreateCardExpirationDateElementOptions, 'targetId'>;
64
64
  declare type CreateCardVerificationCodeElementOptions = CustomizableElementOptions & Pick<ElementOptions, 'placeholder' | 'cardBrand'> & Required<Pick<ElementOptions, 'targetId'>> & {
@@ -3,5 +3,5 @@ import type { CreateToken as CreateTokenModel, UpdateToken as UpdateTokenModel,
3
3
  import type { Create, Retrieve, Update } from '../../../types/sdk';
4
4
  declare type CreateToken = CreateTokenModel<ElementValue>;
5
5
  declare type UpdateToken = UpdateTokenModel<ElementValue>;
6
- declare type Tokens = Create<Token, CreateToken> & Retrieve<Token> & Update<Token, UpdateToken>;
6
+ declare type Tokens = Create<Token, CreateToken> & Retrieve<Token<any>> & Update<Token, UpdateToken>;
7
7
  export type { Tokens, CreateToken, UpdateToken };
@@ -1,5 +1,5 @@
1
1
  import type { Auditable } from './shared';
2
- declare const APPLICATION_TYPES: readonly ["private", "public", "management"];
2
+ declare const APPLICATION_TYPES: readonly ["private", "public", "management", "expiring"];
3
3
  declare const TRANSFORM_TYPES: readonly ["mask", "redact", "reveal"];
4
4
  declare type ApplicationType = typeof APPLICATION_TYPES[number];
5
5
  declare type TransformType = typeof TRANSFORM_TYPES[number];
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.TRANSFORM_TYPES = exports.APPLICATION_TYPES = void 0;
7
- const APPLICATION_TYPES = ['private', 'public', 'management'];
7
+ const APPLICATION_TYPES = ['private', 'public', 'management', 'expiring'];
8
8
  exports.APPLICATION_TYPES = APPLICATION_TYPES;
9
9
  const TRANSFORM_TYPES = ['mask', 'redact', 'reveal'];
10
10
  exports.TRANSFORM_TYPES = TRANSFORM_TYPES;
@@ -10,7 +10,7 @@ interface SearchTokensRequest {
10
10
  page?: number;
11
11
  size?: number;
12
12
  }
13
- interface Tokens extends Create<Token, CreateToken>, Update<Token, UpdateToken>, Retrieve<Token>, Delete, List<Token, ListTokensQuery> {
13
+ interface Tokens extends Create<Token, CreateToken>, Update<Token, UpdateToken>, Retrieve<Token<any>>, Delete, List<Token, ListTokensQuery> {
14
14
  createAssociation(parentId: string, childId: string, options?: RequestOptions): Promise<void>;
15
15
  deleteAssociation(parentId: string, childId: string, options?: RequestOptions): Promise<void>;
16
16
  createChild(parentId: string, token: CreateToken, options?: RequestOptions): Promise<Token>;