Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions demo/Collect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,13 @@ import {
TextInput,
View,
} from 'react-native';
import type { BTRef, BTDateRef, ElementEvent } from '../src';
import type { BTRef, BTDateRef, ElementEvent, Token, TokenizeData } from '../src';
import {
CardExpirationDateElement,
CardNumberElement,
CardVerificationCodeElement,
useBasisTheory,
} from '../src';
import type {
Token,
TokenizeData,
} from '@basis-theory/basis-theory-js/types/models';
import { styles } from './styles';
import type { ElementEvents } from '../App';
import { EncryptedToken, EncryptToken } from '../src/model/EncryptTokenData';
Expand Down Expand Up @@ -314,3 +310,4 @@ export const Collect = () => {
</View>
);
};

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"test": "jest"
},
"dependencies": {
"@basis-theory/basis-theory-js": "^4.28.2",
"@noble/ciphers": "^1.3.0",
"@noble/curves": "^1.9.2",
"@noble/hashes": "^1.8.0",
Expand Down
2 changes: 1 addition & 1 deletion src/components/CardNumberElement.hook.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CreditCardType } from '@basis-theory/basis-theory-js/types/elements';
import type { CreditCardType } from '../types';
import type { ForwardedRef } from 'react';
import { useId, useRef, useState } from 'react';
import type { TextInput } from 'react-native';
Expand Down
2 changes: 1 addition & 1 deletion src/components/useCustomBin.hook.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { CreditCardType } from '@basis-theory/basis-theory-js/types/elements';
import type { CreditCardType } from '../types';
import { creditCardType } from 'card-validator';
import { always, compose, groupBy, ifElse, isEmpty } from 'ramda';
import { useEffect, useState } from 'react';
Expand Down
26 changes: 25 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,28 @@ export { TextElement } from './components/TextElement';
export { BasisTheoryProvider } from './BasisTheoryProvider';
export { useBasisTheory } from './useBasisTheory';
export type { BTRef, BTDateRef, ElementEvent } from './BaseElementTypes';
export type { Token } from '@basis-theory/basis-theory-js/types/models';
export type {
Token,
CreateToken,
UpdateToken,
TokenizeData,
CreateSessionResponse,
CreateTokenIntent,
TokenIntent,
RequestOptions,
DeviceInfo,
BasisTheoryInstance,
CreditCardType,
VISA,
MASTERCARD,
AMERICAN_EXPRESS,
DINERS_CLUB,
DISCOVER,
JCB,
UNIONPAY,
MAESTRO,
ELO,
MIR,
HIPER,
HIPERCARD,
} from './types';
14 changes: 6 additions & 8 deletions src/model/EncryptTokenData.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
// TODO: Migrate to web-elements when we completely drop basis-theory-js
import {
CreateToken,
Primitive,
TokenBase,
} from '@basis-theory/basis-theory-js/types/models';
import type { CreateToken } from '../types';
import { BTRef, InputBTRefWithDatepart } from '../BaseElementTypes';

/**
* Represents token data with element references for secure input handling.
* Used when creating tokens that contain form element references instead of raw values.
*/
// Primitive types
type Primitive = string | number | boolean | null | undefined;

type TokenDataWithRef = {
/** Key-value pairs where values are element references or date part references */
data: Record<string, BTRef | InputBTRefWithDatepart | null | undefined | Primitive>;
type: TokenBase['type'];
type: string;
};

type TokenData = Pick<CreateToken, 'type' | 'data'>;
Expand Down Expand Up @@ -44,7 +42,7 @@ type EncryptedSingleToken = {
encrypted: string;

/** Original token type before encryption */
type: TokenBase['type'];
type: string;
};

type EncryptedToken = EncryptedSingleToken | Record<string, EncryptedSingleToken>;
Expand Down
10 changes: 3 additions & 7 deletions src/modules/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import type { BasisTheory } from '@basis-theory/basis-theory-js';
import type {
ProxyRequestOptions,
BasisTheory as BasisTheoryType,
} from '@basis-theory/basis-theory-js/types/sdk';
import type { ProxyRequestOptions, BasisTheoryInstance } from '../types';

import { replaceSensitiveData } from '../utils/dataManipulationUtils';

export const Proxy = (bt: BasisTheoryType) => {
export const Proxy = (bt: BasisTheoryInstance) => {
const proxy = async (
{
method,
...proxyRequest
}: Omit<ProxyRequestOptions, 'includeResponseHeaders'> & {
method: keyof BasisTheory['proxy'];
method: keyof BasisTheoryInstance['proxy'];
},
apiKey?: string
): Promise<unknown> => {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/sessions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { BasisTheory as BasisTheoryType } from '@basis-theory/basis-theory-js/types/sdk';
import type { BasisTheoryInstance } from '../types';

export const Sessions = (bt: BasisTheoryType) => {
export const Sessions = (bt: BasisTheoryInstance) => {
const create = async () => {
try {
const session = await bt.sessions.create();
Expand Down
8 changes: 3 additions & 5 deletions src/modules/tokenIntents.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import type {
CreateTokenIntent,
TokenIntent,
} from '@basis-theory/basis-theory-js/types/models';
import type {
BasisTheory as BasisTheoryType,
RequestOptions,
} from '@basis-theory/basis-theory-js/types/sdk';
BasisTheoryInstance,
} from '../types';
import type {
BTRef,
InputBTRefWithDatepart,
Expand All @@ -23,7 +21,7 @@ export type TokenIntentData = TokenIntent<
BTRef | InputBTRefWithDatepart | PrimitiveType
>;

export const TokenIntents = (bt: BasisTheoryType) => {
export const TokenIntents = (bt: BasisTheoryInstance) => {
const create = async (
tokenIntentWithRef: CreateTokenIntentWithBtRef,
requestOptions?: RequestOptions
Expand Down
8 changes: 3 additions & 5 deletions src/modules/tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import type {
UpdateToken,
Token,
TokenizeData as _TokenizeData,
} from '@basis-theory/basis-theory-js/types/models';
import type {
BasisTheory as BasisTheoryType,
RequestOptions,
} from '@basis-theory/basis-theory-js/types/sdk';
BasisTheoryInstance,
} from '../types';
import type {
BTRef,
InputBTRefWithDatepart,
Expand Down Expand Up @@ -37,7 +35,7 @@ export type TokenizeData = _TokenizeData<
BTRef | InputBTRefWithDatepart | PrimitiveType
>;

export const Tokens = (bt: BasisTheoryType) => {
export const Tokens = (bt: BasisTheoryInstance) => {
setupEncryption();

const getTokenById = async <T>(id: string, apiKey?: string) => {
Expand Down
Loading