@basis-theory/react-elements 1.14.1 → 1.16.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 (2) hide show
  1. package/package.json +2 -2
  2. package/types/index.d.ts +39 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/react-elements",
3
- "version": "1.14.1",
3
+ "version": "1.16.0",
4
4
  "repository": "https://github.com/basis-theory/react-elements",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,7 +30,7 @@
30
30
  "tag": "latest"
31
31
  },
32
32
  "dependencies": {
33
- "@basis-theory/web-elements": "1.14.1"
33
+ "@basis-theory/web-elements": "1.16.0"
34
34
  },
35
35
  "peerDependencies": {
36
36
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0",
package/types/index.d.ts CHANGED
@@ -361,6 +361,17 @@ export type UpdateTokenModel<DataType = Primitive> = Partial<Pick<Token<DataType
361
361
  privacy: Omit<TokenPrivacy, 'classification'>;
362
362
  deduplicateToken: boolean;
363
363
  }>;
364
+ export type EncryptTokenModel<DataType = Primitive> = {
365
+ tokenRequests: {
366
+ [key: string]: Pick<CreateTokenModel<DataType>, 'data' | 'type'>;
367
+ } | Pick<CreateTokenModel<DataType>, 'data' | 'type'>;
368
+ public_key: string;
369
+ key_id: string;
370
+ };
371
+ export type EncryptedToken = {
372
+ encrypted: string;
373
+ type: TokenBase['type'];
374
+ };
364
375
  export type TokenizeObject<DataType = Primitive> = {
365
376
  [key: string]: Primitive | TokenizeObject<DataType> | TokenizeArray<DataType> | DataType;
366
377
  };
@@ -435,13 +446,17 @@ type Retrieve<T> = {
435
446
  type Update<T, U> = {
436
447
  update(id: string, model: U, options?: RequestOptions): Promise<T>;
437
448
  };
449
+ type Encrypt<E, T> = {
450
+ encrypt(model: T, options?: RequestOptions): Promise<E>;
451
+ };
438
452
  export type TokenizeData = TokenizeDataModel<ElementValue>;
439
453
  export interface Tokenize {
440
454
  tokenize(tokens: TokenizeData, options?: RequestOptions): Promise<TokenizeDataModel>;
441
455
  }
442
456
  export type CreateToken = CreateTokenModel<ElementValue>;
443
457
  export type UpdateToken = UpdateTokenModel<ElementValue>;
444
- export type Tokens = Create<Token, CreateToken> & Retrieve<Token<any>> & Update<Token, UpdateToken>;
458
+ type EncryptToken = EncryptTokenModel<ElementValue>;
459
+ export type Tokens = Create<Token, CreateToken> & Retrieve<Token<any>> & Update<Token, UpdateToken> & Encrypt<EncryptedToken, EncryptToken>;
445
460
  type BasisTheoryProxyHeaders = {
446
461
  [key: string]: string;
447
462
  'BT-PROXY-URL': string;
@@ -552,6 +567,29 @@ export interface BasisTheoryInitOptions {
552
567
  debug?: boolean;
553
568
  }
554
569
  export const basistheory: (apiKey: string, options?: BasisTheoryInitOptions) => Promise<BasisTheoryElements | undefined>;
570
+ export class BasisTheoryApiError extends Error {
571
+ readonly status: number;
572
+ readonly data?: unknown | undefined;
573
+ constructor(message: string, status: number, data?: unknown | undefined);
574
+ }
575
+ export class BasisTheoryValidationError<Details = Record<string, unknown>> extends Error {
576
+ readonly details: Details;
577
+ /**
578
+ * @deprecated use {@link details}
579
+ */
580
+ readonly validation?: FieldError[] | undefined;
581
+ constructor(message: string, details: Details,
582
+ /**
583
+ * @deprecated use {@link details}
584
+ */
585
+ validation?: FieldError[] | undefined);
586
+ }
587
+ export class HttpClientError extends Error {
588
+ readonly status: number;
589
+ readonly data?: unknown;
590
+ readonly headers?: unknown;
591
+ constructor(message: string, status: number, data?: unknown, headers?: unknown);
592
+ }
555
593
  declare global {
556
594
  interface Window {
557
595
  basistheory?: typeof basistheory;