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
46 changes: 46 additions & 0 deletions demo/Collect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import type {
} from '@basis-theory/basis-theory-js/types/models';
import { styles } from './styles';
import type { ElementEvents } from '../App';
import { EncryptedToken, EncryptToken } from '../src/model/EncryptTokenData';

const Divider = () => <View style={styles.divider} />;

Expand All @@ -32,6 +33,7 @@ export const Collect = () => {
const [tokenizedData, setTokenizedData] = useState<
TokenizeData | undefined
>();
const [encryptedToken, setEncryptedToken] = useState<EncryptedToken[] | undefined>();

const [tokenId, setTokenId] = useState('');

Expand Down Expand Up @@ -142,6 +144,30 @@ export const Collect = () => {
}
};

const encryptToken = async () => {
try {
const encryptRequest: EncryptToken = {
tokenRequests: {
type: 'card',
data: {
number: cardNumberRef.current,
expiration_month: cardExpirationDateRef.current?.month(),
expiration_year: cardExpirationDateRef.current?.year(),
cvc: cardVerificationCodeRef.current,
},
},
// public key from dev environment
publicKeyPEM: '-----BEGIN PUBLIC KEY-----\noCXqWBAnKV24Xt1/lCVzN3fg1w8INuCRcp8B0EwmbxA=\n-----END PUBLIC KEY-----',
keyId: '1c6e6249-9c55-47a1-a8c4-73c0b3d60a64'
};

const encrypted = await bt?.tokens.encrypt(encryptRequest);
setEncryptedToken(encrypted);
} catch (error) {
console.error(error);
}
};

const clearToken = () => {
cardExpirationDateRef.current?.clear();
cardNumberRef.current?.clear();
Expand All @@ -150,6 +176,7 @@ export const Collect = () => {
setTokenId('');
setToken(undefined);
setTokenizedData(undefined);
setEncryptedToken(undefined);
};

return (
Expand Down Expand Up @@ -230,6 +257,15 @@ export const Collect = () => {
<Text style={styles.buttonText}>{'Tokenize Data'}</Text>
</Pressable>

<Pressable
onPress={encryptToken}
style={{
...styles.button,
}}
>
<Text style={styles.buttonText}>{'Encrypt Token'}</Text>
</Pressable>

<Divider />

<Pressable onPress={clearToken} style={styles.button}>
Expand All @@ -256,6 +292,16 @@ export const Collect = () => {
</Text>
</>
)}

{encryptedToken && (
<>
<Divider />
<Text style={styles.text}>ENCRYPTED TOKEN: </Text>
<Text style={styles.text}>
{JSON.stringify(encryptedToken, undefined, 2)}
</Text>
</>
)}
</View>
</ScrollView>
</SafeAreaView>
Expand Down
109 changes: 55 additions & 54 deletions ios/AwesomeProject.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

68 changes: 34 additions & 34 deletions ios/AwesomeProject/PrivacyInfo.xcprivacy
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array />
<key>NSPrivacyTracking</key>
<false />
</dict>
</plist>
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>C617.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategoryUserDefaults</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
</array>
</dict>
<dict>
<key>NSPrivacyAccessedAPIType</key>
<string>NSPrivacyAccessedAPICategorySystemBootTime</string>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>35F9.1</string>
</array>
</dict>
</array>
<key>NSPrivacyCollectedDataTypes</key>
<array/>
<key>NSPrivacyTracking</key>
<false/>
</dict>
</plist>
Loading