@basis-theory/basis-theory-js 4.10.0 → 4.11.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/common/utils.d.ts CHANGED
@@ -1,14 +1,15 @@
1
1
  import type { AxiosRequestConfig, AxiosResponse, AxiosRequestTransformer, AxiosResponseTransformer } from 'axios';
2
2
  import type { RequestTransformers } from '../service';
3
- import type { Reactor, Proxy, Token, CreateReactor, UpdateReactor, CreateToken, UpdateToken, CreateProxy, UpdateProxy } from '../types/models';
3
+ import type { Reactor, Proxy, Token, CreateReactor, UpdateReactor, CreateProxy, UpdateProxy, Primitive } from '../types/models';
4
4
  import type { ApplicationInfo, PaginatedList, ProxyRequestOptions, RequestOptions } from '../types/sdk';
5
5
  declare const assertInit: <T>(prop: T) => NonNullable<T>;
6
6
  declare const transformRequestSnakeCase: <T, S>(data: T) => S | undefined;
7
7
  declare const proxyRaw: <T>(data: T) => T | undefined;
8
8
  declare const transformReactorRequestSnakeCase: (reactor: Reactor | CreateReactor | UpdateReactor) => Reactor | CreateReactor | UpdateReactor | undefined;
9
9
  declare const transformProxyRequestSnakeCase: (proxy: Proxy | CreateProxy | UpdateProxy) => Proxy | CreateProxy | UpdateProxy | undefined;
10
- declare const transformTokenRequestSnakeCase: (token: Token | CreateToken | UpdateToken) => Token | CreateToken | UpdateToken | undefined;
11
- declare const transformTokenResponseCamelCase: (tokenResponse: Token | PaginatedList<Token> | undefined) => Token | PaginatedList<Token> | undefined;
10
+ type TokenLike<DataType> = Partial<Token<DataType>> & Record<string, unknown>;
11
+ declare const transformTokenRequestSnakeCase: <DataType = Primitive>(payload: TokenLike<DataType>) => TokenLike<DataType> | undefined;
12
+ declare const transformTokenResponseCamelCase: <DataType = Primitive>(tokenResponse: PaginatedList<Token> | TokenLike<DataType> | undefined) => PaginatedList<Token> | TokenLike<DataType> | undefined;
12
13
  declare const transformReactorResponseCamelCase: (reactorResponse: Reactor | PaginatedList<Reactor> | undefined) => Reactor | PaginatedList<Reactor> | undefined;
13
14
  declare const transformProxyResponseCamelCase: (proxyResponse: Proxy | PaginatedList<Proxy> | undefined) => Proxy | PaginatedList<Proxy> | undefined;
14
15
  declare const transformResponseCamelCase: <T, C>(data: T) => C | undefined;
package/common/utils.js CHANGED
@@ -79,19 +79,19 @@ const transformProxyRequestSnakeCase = proxy => {
79
79
 
80
80
  exports.transformProxyRequestSnakeCase = transformProxyRequestSnakeCase;
81
81
 
82
- const transformTokenRequestSnakeCase = token => {
83
- if (typeof token === 'undefined') {
82
+ const transformTokenRequestSnakeCase = payload => {
83
+ if (typeof payload === 'undefined') {
84
84
  return undefined;
85
85
  }
86
86
 
87
- return { ...(0, _snakecaseKeys.default)(token, {
87
+ return { ...(0, _snakecaseKeys.default)(payload, {
88
88
  deep: true
89
89
  }),
90
- ...(token.data !== undefined ? {
91
- data: token.data
90
+ ...(payload.data !== undefined ? {
91
+ data: payload.data
92
92
  } : {}),
93
- ...(token.metadata !== undefined ? {
94
- metadata: token.metadata
93
+ ...(payload.metadata !== undefined ? {
94
+ metadata: payload.metadata
95
95
  } : {})
96
96
  };
97
97
  };
@@ -4,5 +4,5 @@ declare const ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE = "Basis Theory Elements did no
4
4
  declare const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = "There was an unknown error when loading Basis Theory Elements. Check the console for details.";
5
5
  declare const CARD_BRANDS: readonly ["visa", "mastercard", "american-express", "discover", "diners-club", "jcb", "unionpay", "maestro", "elo", "hiper", "hipercard", "mir", "unknown"];
6
6
  declare const CARD_ICON_POSITIONS: readonly ["left", "right", "none"];
7
- declare const AUTOCOMPLETE_VALUES: readonly ["off", "on"];
7
+ 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"];
8
8
  export { ELEMENTS_INIT_ERROR_MESSAGE, ELEMENTS_NOM_DOM_ERROR_MESSAGE, ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE, ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE, CARD_BRANDS, CARD_ICON_POSITIONS, AUTOCOMPLETE_VALUES, };
@@ -14,7 +14,8 @@ const ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = 'There was an unknown error when l
14
14
  exports.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE = ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE;
15
15
  const CARD_BRANDS = ['visa', 'mastercard', 'american-express', 'discover', 'diners-club', 'jcb', 'unionpay', 'maestro', 'elo', 'hiper', 'hipercard', 'mir', 'unknown'];
16
16
  exports.CARD_BRANDS = CARD_BRANDS;
17
- const CARD_ICON_POSITIONS = ['left', 'right', 'none'];
17
+ const CARD_ICON_POSITIONS = ['left', 'right', 'none']; // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
18
+
18
19
  exports.CARD_ICON_POSITIONS = CARD_ICON_POSITIONS;
19
- const AUTOCOMPLETE_VALUES = ['off', 'on'];
20
+ const AUTOCOMPLETE_VALUES = ['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'];
20
21
  exports.AUTOCOMPLETE_VALUES = AUTOCOMPLETE_VALUES;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-js",
3
- "version": "4.10.0",
3
+ "version": "4.11.0",
4
4
  "repository": "https://github.com/Basis-Theory/basis-theory-js",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -1,7 +1,8 @@
1
+ import { BasisTheoryServiceOptions } from '../service';
1
2
  import type { TokenIntent, CreateTokenIntent } from '../types/models';
2
3
  export declare const BasisTheoryTokenIntents: {
3
- new (options: import("../service/types").BasisTheoryServiceOptions): {
4
+ new (options: BasisTheoryServiceOptions): {
4
5
  readonly client: import("axios").AxiosInstance;
5
6
  };
6
- } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<TokenIntent<import("../types/models/tokens").DataObject>, CreateTokenIntent>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete);
7
+ } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<TokenIntent, CreateTokenIntent>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete);
7
8
  export type BasisTheoryTokenIntents = InstanceType<typeof BasisTheoryTokenIntents>;
@@ -5,9 +5,21 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.BasisTheoryTokenIntents = void 0;
7
7
 
8
+ var _common = require("./../common");
9
+
8
10
  var _service = require("./../service");
9
11
 
10
12
  var _CrudBuilder = require("./../service/CrudBuilder");
11
13
 
12
- const BasisTheoryTokenIntents = new _CrudBuilder.CrudBuilder(class BasisTheoryTokenIntents extends _service.BasisTheoryService {}).create().delete().build();
14
+ const BasisTheoryTokenIntents = new _CrudBuilder.CrudBuilder(class BasisTheoryTokenIntents extends _service.BasisTheoryService {
15
+ constructor(options) {
16
+ const _options = options; // eslint-disable-next-line unicorn/prefer-spread
17
+
18
+ _options.transformRequest = [].concat(_common.transformTokenRequestSnakeCase, options.transformRequest || []); // eslint-disable-next-line unicorn/prefer-spread
19
+
20
+ _options.transformResponse = [].concat(_common.transformTokenResponseCamelCase, options.transformResponse || []);
21
+ super(_options);
22
+ }
23
+
24
+ }).create().delete().build();
13
25
  exports.BasisTheoryTokenIntents = BasisTheoryTokenIntents;
@@ -8,5 +8,5 @@ export declare const BasisTheoryTokens: {
8
8
  search(searchRequest: SearchTokensRequest, options?: RequestOptions): Promise<PaginatedList<Token>>;
9
9
  readonly client: import("axios").AxiosInstance;
10
10
  };
11
- } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token<import("../types/models/shared").Primitive>, CreateToken>) & (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>);
11
+ } & (new (...args: any[]) => import("../types/sdk/services/shared").Create<Token, CreateToken>) & (new (...args: any[]) => import("../types/sdk/services/shared").Delete) & (new (...args: any[]) => import("../types/sdk/services/shared").List<Token, ListTokensQuery>);
12
12
  export type BasisTheoryTokens = InstanceType<typeof BasisTheoryTokens>;
@@ -22,7 +22,7 @@ declare enum InputMode {
22
22
  interface SanitizedElementOptions {
23
23
  ariaDescription?: string;
24
24
  ariaLabel?: string;
25
- autoComplete?: string;
25
+ autoComplete?: AutoCompleteValue;
26
26
  cardBrand?: string;
27
27
  cardTypes?: CreditCardType[];
28
28
  copyIconStyles?: CopyIconStyles;
@@ -1,4 +1,3 @@
1
- import type { DataObject } from './tokens';
2
1
  type Primitive = string | number | boolean | null;
3
2
  type TokenType = 'token' | 'card' | 'bank' | 'card_number' | 'us_bank_routing_number' | 'us_bank_account_number' | 'social_security_number';
4
3
  interface Auditable {
@@ -7,15 +6,17 @@ interface Auditable {
7
6
  modifiedBy?: string;
8
7
  modifiedAt?: string;
9
8
  }
10
- interface TokenBase<T extends TokenType = TokenType> extends Auditable {
11
- id: string;
12
- type: T;
13
- tenantId: string;
14
- fingerprint?: string;
15
- metadata?: Record<string, string>;
9
+ type DataObject<DataType = Primitive> = {
10
+ [member: string]: TokenData<DataType>;
11
+ };
12
+ type DataArray<DataType> = Array<TokenData<DataType>>;
13
+ type TokenData<DataType = Primitive> = Primitive | DataObject<DataType> | DataArray<DataType> | DataType;
14
+ interface TokenBase<DataType = Primitive> extends Auditable {
15
+ data: TokenData<DataType>;
16
+ type: TokenType;
16
17
  }
17
18
  interface ReactResponse {
18
19
  tokens: DataObject;
19
20
  raw: DataObject;
20
21
  }
21
- export type { Primitive, Auditable, TokenType, TokenBase, ReactResponse };
22
+ export type { Primitive, Auditable, TokenType, TokenBase, ReactResponse, DataObject, };
@@ -1,22 +1,28 @@
1
- import type { DataObject, TokenData, Auditable, TokenType } from '../../types/models';
1
+ import type { TokenBase, DataObject, Auditable, TokenType } from '../../types/models';
2
2
  interface TokenIntentCardDetails {
3
- cardDetails: {
3
+ type: 'card';
4
+ card: {
4
5
  bin: string;
5
6
  last4: string;
6
7
  brand: string;
7
- type: string;
8
- expirationMonth: string;
9
- expirationYear: string;
8
+ funding: string;
9
+ expirationMonth: number;
10
+ expirationYear: number;
10
11
  };
11
12
  }
12
- interface TokenIntent<DataType = DataObject> extends Omit<Auditable, 'modifiedAt' | 'modifiedBy'> {
13
- data: TokenData<DataType>;
14
- type: TokenType;
15
- enrichments?: TokenIntentCardDetails;
13
+ type TokenTypesForTokenIntents = Exclude<TokenType, 'token' | 'card'>;
14
+ type TokenTypeMap = {
15
+ [K in TokenTypesForTokenIntents]: {
16
+ type: K;
17
+ } & Record<K, Record<string, unknown>>;
18
+ };
19
+ type TokenIntent<DataType = DataObject> = (TokenBase<DataType> & Omit<Auditable, 'modifiedAt' | 'modifiedBy'> & {
20
+ id: string;
16
21
  tenantId: string;
17
22
  expiresAt: string;
18
- }
19
- type CreateTokenIntent<DataType = DataObject> = Pick<TokenIntent<DataType>, 'type' | 'data'> & {
20
- id: string;
21
- };
23
+ fingerprint?: string;
24
+ }) & (TokenTypeMap[TokenTypesForTokenIntents] | TokenIntentCardDetails | {
25
+ type: 'token';
26
+ });
27
+ type CreateTokenIntent<DataType = DataObject> = Pick<TokenIntent<DataType>, 'type' | 'data'>;
22
28
  export type { TokenIntent, CreateTokenIntent, TokenIntentCardDetails };
@@ -6,11 +6,6 @@ declare const DATA_IMPACT_LEVELS: readonly ["low", "moderate", "high"];
6
6
  type DataImpactLevel = typeof DATA_IMPACT_LEVELS[number];
7
7
  declare const DATA_RESTRICTION_POLICIES: readonly ["mask", "redact"];
8
8
  type DataRestrictionPolicy = typeof DATA_RESTRICTION_POLICIES[number];
9
- type DataObject<DataType = Primitive> = {
10
- [member: string]: TokenData<DataType>;
11
- };
12
- type DataArray<DataType> = Array<TokenData<DataType>>;
13
- type TokenData<DataType = Primitive> = Primitive | DataObject<DataType> | DataArray<DataType> | DataType;
14
9
  type MaskObject = {
15
10
  [member: string]: TokenMask;
16
11
  };
@@ -32,8 +27,8 @@ interface TokenPrivacy {
32
27
  interface TokenEnrichments {
33
28
  binDetails?: BinDetails;
34
29
  }
35
- interface Token<DataType = Primitive> extends TokenBase {
36
- data: TokenData<DataType>;
30
+ type Token<DataType = Primitive> = TokenBase<DataType> & {
31
+ id: string;
37
32
  privacy?: TokenPrivacy;
38
33
  containers?: string[];
39
34
  encryption?: TokenEncryption;
@@ -42,7 +37,10 @@ interface Token<DataType = Primitive> extends TokenBase {
42
37
  mask?: TokenMask;
43
38
  expiresAt?: string;
44
39
  enrichments?: TokenEnrichments;
45
- }
40
+ tenantId: string;
41
+ fingerprint?: string;
42
+ metadata?: Record<string, string>;
43
+ };
46
44
  type CreateToken<DataType = Primitive> = Pick<Token<DataType>, 'type' | 'data' | 'privacy' | 'containers' | 'metadata' | 'encryption' | 'searchIndexes' | 'fingerprintExpression' | 'mask' | 'expiresAt'> & {
47
45
  deduplicateToken?: boolean;
48
46
  id?: string;
@@ -51,5 +49,5 @@ type UpdateToken<DataType = Primitive> = Partial<Pick<Token<DataType>, 'data' |
51
49
  privacy: Omit<TokenPrivacy, 'classification'>;
52
50
  deduplicateToken: boolean;
53
51
  }>;
54
- export type { Token, TokenEnrichments, CreateToken, UpdateToken, DataArray, DataObject, TokenData, DataClassification, DataImpactLevel, DataRestrictionPolicy, };
52
+ export type { Token, TokenEnrichments, CreateToken, UpdateToken, DataClassification, DataImpactLevel, DataRestrictionPolicy, };
55
53
  export { DATA_CLASSIFICATIONS, DATA_IMPACT_LEVELS, DATA_RESTRICTION_POLICIES };