@basis-theory/basis-theory-js 1.79.2 → 1.79.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/BasisTheory.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import { Config } from './common/BasisTheoryClient';
2
- import type { BasisTheoryElements, CardElement, CardNumberElement, CardExpirationDateElement, CardVerificationCodeElement, CreateCardElementOptions, CreateCardNumberElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from './types/elements';
1
+ import type { BasisTheoryElements, CardElement, CardExpirationDateElement, CardNumberElement, CardVerificationCodeElement, CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardNumberElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, TextElement, TokenizeData as ElementsTokenizeData, Tokens as ElementsTokens } from './types/elements';
3
2
  import type { TokenizeData } from './types/models';
4
- import type { Applications, BasisTheory as IBasisTheory, BasisTheoryInit, Logs, Permissions, ReactorFormulas, Reactors, RequestOptions, Tenants, Tokens, BasisTheoryInitOptions, BasisTheoryInitOptionsWithElements, BasisTheoryInitOptionsWithoutElements, Proxies, Proxy, Sessions } from './types/sdk';
3
+ import type { Applications, BasisTheory as IBasisTheory, BasisTheoryInit, BasisTheoryInitOptions, BasisTheoryInitOptionsWithElements, BasisTheoryInitOptionsWithoutElements, Logs, Permissions, Proxies, Proxy, ReactorFormulas, Reactors, RequestConfig, RequestOptions, Sessions, Tenants, Tokens } from './types/sdk';
5
4
  import { Transactions } from './types/sdk/services/transactions';
6
5
  export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, BasisTheoryElements {
7
6
  private _initStatus;
@@ -27,11 +26,11 @@ export declare class BasisTheory implements BasisTheoryInit, IBasisTheory, Basis
27
26
  createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
28
27
  createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
29
28
  tokenize(tokens: TokenizeData & ElementsTokenizeData, options?: RequestOptions): Promise<TokenizeData>;
30
- post(url: string, payload: unknown, config?: Config): Promise<unknown>;
31
- put(url: string, payload: unknown, config?: Config): Promise<unknown>;
32
- patch(url: string, payload: unknown, config?: Config): Promise<unknown>;
33
- get(url: string, config?: Config): Promise<unknown>;
34
- delete(url: string, config?: Config): Promise<unknown>;
29
+ post(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
30
+ put(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
31
+ patch(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
32
+ get(url: string, config?: RequestConfig): Promise<unknown>;
33
+ delete(url: string, config?: RequestConfig): Promise<unknown>;
35
34
  private loadElements;
36
35
  get initOptions(): Required<BasisTheoryInitOptions>;
37
36
  get tokens(): Tokens & ElementsTokens;
@@ -1,9 +1,7 @@
1
1
  import type { BasisTheoryElementsInternal } from '../types/elements';
2
- type Config = {
3
- headers?: Record<string, string>;
4
- };
2
+ import type { RequestConfig } from '../types/sdk';
5
3
  type MethodWithPayloads = 'post' | 'put' | 'patch';
6
4
  type MethodWithoutPayloads = 'get' | 'delete';
7
- declare const makeRequestWithElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithPayloads, url: string, payload: unknown, config?: Config) => Promise<unknown>;
8
- declare const makeRequestWithoutElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithoutPayloads, url: string, config?: Config) => Promise<unknown>;
9
- export { Config, makeRequestWithElementsPayloadCheck, makeRequestWithoutElementsPayloadCheck, };
5
+ declare const makeRequestWithElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithPayloads, url: string, payload: unknown, config?: RequestConfig) => Promise<unknown>;
6
+ declare const makeRequestWithoutElementsPayloadCheck: (elements: BasisTheoryElementsInternal | undefined, method: MethodWithoutPayloads, url: string, config?: RequestConfig) => Promise<unknown>;
7
+ export { makeRequestWithElementsPayloadCheck, makeRequestWithoutElementsPayloadCheck, };
package/common/utils.js CHANGED
@@ -375,12 +375,21 @@ const getBrowser = () => {
375
375
  }
376
376
 
377
377
  return `${(browser === null || browser === void 0 ? void 0 : browser.browserName) || 'unknown'}/${version}`;
378
- };
378
+ }; // the following product property is deprecated but it's the only way
379
+ // I've found to detect react-native
380
+
379
381
 
380
382
  exports.getBrowser = getBrowser;
381
383
 
384
+ const isEnvReactNative = () => typeof window === 'object' && window.navigator.product === 'ReactNative';
385
+
382
386
  const getOSVersion = () => {
383
- // node
387
+ // react-native
388
+ if (isEnvReactNative()) {
389
+ return 'ReactNative';
390
+ } // node
391
+
392
+
384
393
  if (typeof window === 'undefined') {
385
394
  try {
386
395
  return `${_os.default.type()}/${_os.default.version()}`;
@@ -407,7 +416,12 @@ const getOSVersion = () => {
407
416
  exports.getOSVersion = getOSVersion;
408
417
 
409
418
  const getRuntime = () => {
410
- // node
419
+ // react-native
420
+ if (isEnvReactNative()) {
421
+ return 'ReactNative';
422
+ } // node
423
+
424
+
411
425
  if (typeof window === 'undefined') {
412
426
  return `NodeJS/${process.version}`;
413
427
  } // browser
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@basis-theory/basis-theory-js",
3
- "version": "1.79.2",
3
+ "version": "1.79.4",
4
4
  "repository": "https://github.com/Basis-Theory/basis-theory-js",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -1,7 +1,7 @@
1
- import type { Config } from '../../common/BasisTheoryClient';
2
- import type { ElementEventListener, EventType, Subscription, TextElementEvents, CardElementEvents, CardNumberElementEvents, CardExpirationDateElementEvents, CardVerificationCodeElementEvents } from './events';
3
- import type { CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, UpdateCardElementOptions, CreateCardNumberElementOptions, UpdateCardNumberElementOptions, UpdateCardExpirationDateElementOptions, UpdateCardVerificationCodeElementOptions, UpdateTextElementOptions, CardElementValue, CardExpirationDateValue } from './options';
4
- import type { Tokenize, Tokens, Proxy } from './services';
1
+ import type { HttpClient } from '../../types/sdk';
2
+ import type { CardElementEvents, CardExpirationDateElementEvents, CardNumberElementEvents, CardVerificationCodeElementEvents, ElementEventListener, EventType, Subscription, TextElementEvents } from './events';
3
+ import type { CardElementValue, CardExpirationDateValue, CreateCardElementOptions, CreateCardExpirationDateElementOptions, CreateCardNumberElementOptions, CreateCardVerificationCodeElementOptions, CreateTextElementOptions, UpdateCardElementOptions, UpdateCardExpirationDateElementOptions, UpdateCardNumberElementOptions, UpdateCardVerificationCodeElementOptions, UpdateTextElementOptions } from './options';
4
+ import type { Proxy, Tokenize, Tokens } from './services';
5
5
  import type { CardMetadata, DataElementReference, ElementMetadata } from './shared';
6
6
  interface BaseElement<UpdateOptions, ElementEvents> {
7
7
  readonly mounted: boolean;
@@ -43,7 +43,7 @@ type ElementWrapper<T extends BaseElement<any, any> = BaseElement<any, any>> = {
43
43
  };
44
44
  };
45
45
  type ElementValue = TextElement | CardElement | CardNumberElement | CardExpirationDateElement | CardVerificationCodeElement | ElementWrapper;
46
- interface BasisTheoryElements extends Tokenize {
46
+ interface BasisTheoryElements extends Tokenize, HttpClient {
47
47
  tokens: Tokens;
48
48
  proxy: Proxy;
49
49
  createElement(type: 'card', options?: CreateCardElementOptions): CardElement;
@@ -52,17 +52,10 @@ interface BasisTheoryElements extends Tokenize {
52
52
  createElement(type: 'cardExpirationDate', options: CreateCardExpirationDateElementOptions): CardExpirationDateElement;
53
53
  createElement(type: 'cardVerificationCode', options: CreateCardVerificationCodeElementOptions): CardVerificationCodeElement;
54
54
  }
55
- interface ElementClient {
56
- post(url: string, payload: unknown, config?: Config): Promise<unknown>;
57
- put(url: string, payload: unknown, config?: Config): Promise<unknown>;
58
- patch(url: string, payload: unknown, config?: Config): Promise<unknown>;
59
- get(url: string, config?: Config): Promise<unknown>;
60
- delete(url: string, config?: Config): Promise<unknown>;
61
- }
62
55
  interface BasisTheoryElementsInternal extends BasisTheoryElements {
63
56
  init: (apiKey: string | undefined, elementsBaseUrl: string) => Promise<BasisTheoryElements>;
64
57
  hasElement: (payload: unknown) => boolean;
65
- client: ElementClient;
58
+ client: HttpClient;
66
59
  }
67
60
  declare global {
68
61
  interface Window {
@@ -1,6 +1,6 @@
1
1
  import type { BasisTheoryElements } from '../../types/elements';
2
2
  import { Transactions } from '../../types/sdk/services/transactions';
3
- import type { Tokens, Tokenize, Applications, Tenants, Logs, ReactorFormulas, Reactors, Permissions, Proxies, Proxy, Sessions } from './services';
3
+ import type { Tokens, Tokenize, Applications, Tenants, Logs, ReactorFormulas, Reactors, Permissions, Proxies, Proxy, Sessions, HttpClient } from './services';
4
4
  interface ApplicationInfo {
5
5
  name?: string;
6
6
  version?: string;
@@ -22,7 +22,7 @@ interface BasisTheoryInit {
22
22
  init(apiKey: string, options?: BasisTheoryInitOptionsWithoutElements): Promise<BasisTheory>;
23
23
  init(apiKey: string, options: BasisTheoryInitOptionsWithElements): Promise<BasisTheory & BasisTheoryElements>;
24
24
  }
25
- interface BasisTheory extends Tokenize {
25
+ interface BasisTheory extends Tokenize, HttpClient {
26
26
  tokens: Tokens;
27
27
  applications: Applications;
28
28
  tenants: Tenants;
@@ -42,7 +42,7 @@ interface ClientUserAgent {
42
42
  runtimeVersion: string;
43
43
  application?: ApplicationInfo;
44
44
  }
45
- type BasisTheoryServices = keyof BasisTheory;
45
+ type BasisTheoryServices = keyof Omit<BasisTheory, keyof HttpClient>;
46
46
  type BasisTheoryServicesBasePathMap = {
47
47
  [key in BasisTheoryServices]: string;
48
48
  };
@@ -0,0 +1,11 @@
1
+ interface RequestConfig {
2
+ headers?: Record<string, string>;
3
+ }
4
+ interface HttpClient {
5
+ post(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
6
+ put(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
7
+ patch(url: string, payload: unknown, config?: RequestConfig): Promise<unknown>;
8
+ get(url: string, config?: RequestConfig): Promise<unknown>;
9
+ delete(url: string, config?: RequestConfig): Promise<unknown>;
10
+ }
11
+ export type { HttpClient, RequestConfig };
@@ -0,0 +1 @@
1
+ "use strict";
@@ -11,3 +11,4 @@ export * from './proxies';
11
11
  export * from './proxy';
12
12
  export * from './sessions';
13
13
  export * from './transactions';
14
+ export * from './http';
@@ -171,4 +171,17 @@ Object.keys(_transactions).forEach(function (key) {
171
171
  return _transactions[key];
172
172
  }
173
173
  });
174
+ });
175
+
176
+ var _http = require("./http");
177
+
178
+ Object.keys(_http).forEach(function (key) {
179
+ if (key === "default" || key === "__esModule") return;
180
+ if (key in exports && exports[key] === _http[key]) return;
181
+ Object.defineProperty(exports, key, {
182
+ enumerable: true,
183
+ get: function () {
184
+ return _http[key];
185
+ }
186
+ });
174
187
  });