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
55 changes: 55 additions & 0 deletions MIGRATION_0.1.9-0.2.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Migration Guide: v0.1.9 β†’ v0.2.0

## Breaking Changes

### Import Syntax Changes

**Before (v0.1.9):**
```js
import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';
```

**After (v0.2.0):**
```js
import {
initializeSDKIOS,
setUserId,
triggerAction,
clearUser,
setLogLevel,
TSAction,
type TSActionEventOptions
} from 'react-native-ts-accountprotection';
```

### API Usage Changes

| Function | Before | After |
|----------|--------|-------|
| Initialize iOS | `TSAccountProtectionSDKModule.initializeSDKIOS()` | `initializeSDKIOS()` |
| Set User ID | `TSAccountProtectionSDKModule.setUserId(id)` | `setUserId(id)` |
| Trigger Action | `TSAccountProtectionSDKModule.triggerAction(...)` | `triggerAction(...)` |
| Clear User | `TSAccountProtectionSDKModule.clearUser()` | `clearUser()` |
| Set Log Level | `TSAccountProtectionSDKModule.setLogLevel(...)` | `setLogLevel(...)` |

### Type Reference Changes

| Type | Before | After |
|------|--------|-------|
| Actions | `TSAccountProtectionSDK.TSAction.login` | `TSAction.login` |
| Event Options | `TSAccountProtectionSDK.TSActionEventOptions` | `TSActionEventOptions` |
| Response | `TSAccountProtectionSDK.TSSetActionResponse` | `TSSetActionResponse` |

## Quick Migration Steps

1. **Update imports** - Replace the old import with individual named imports
2. **Remove module prefix** - Remove `TSAccountProtectionSDKModule.` from all function calls
3. **Update type references** - Remove `TSAccountProtectionSDK.` namespace from type references
4. **Add type imports** - Import types with `type` keyword for TypeScript projects

## Benefits

- βœ… Tree-shaking support for smaller bundle sizes
- βœ… Cleaner, more intuitive API
- βœ… Better TypeScript intellisense
- βœ… Follows React Native community standards
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,30 @@ First, [Create](https://developer.transmitsecurity.com/guides/risk/quick_start_i

Next initialize the SDK when your app component is ready
```js
import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';
import { initializeSDKIOS } from 'react-native-ts-accountprotection';

componentDidMount(): void {
// Setup the module as soon your component is ready
await TSAccountProtectionSDKModule.initializeSDKIOS();
await initializeSDKIOS();
}
```

## Module API

#### Set UserID after authentication
```js
await TSAccountProtectionSDKModule.setUserId(username);
import { setUserId } from 'react-native-ts-accountprotection';

await setUserId(username);
```

#### Trigger Action
```js
import { triggerAction, TSAction } from 'react-native-ts-accountprotection';

private handleTriggerActionLoginExample = async () => {
const triggerActionResponse = await TSAccountProtectionSDKModule.triggerAction(
TSAccountProtectionSDK.TSAction.login,
const triggerActionResponse = await triggerAction(
TSAction.login,
{
correlationId: "CORRELATION_ID",
claimUserId: "CLAIM_USER_ID",
Expand All @@ -125,14 +129,18 @@ private handleTriggerActionLoginExample = async () => {

#### Clear User ID
```js
await TSAccountProtectionSDKModule.clearUser();
import { clearUser } from 'react-native-ts-accountprotection';

await clearUser();
```

#### Set Log Level (Optional)
Enable or disable SDK debug logging:
```js
await TSAccountProtectionSDKModule.setLogLevel(true); // Enable debug logging
await TSAccountProtectionSDKModule.setLogLevel(false); // Disable debug logging
import { setLogLevel } from 'react-native-ts-accountprotection';

await setLogLevel(true); // Enable debug logging
await setLogLevel(false); // Disable debug logging
```

## Important
Expand Down
45 changes: 45 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,50 @@
# Release Notes

## Version 0.2.0

### πŸš€ Major API Refactor - Breaking Changes

This release introduces a significant improvement to the module's API design, transitioning from a mixed export pattern to clean named exports. This change aligns with modern React Native best practices and provides a better developer experience.

### Breaking Changes
- **Removed default export**: The module no longer exports a default class instance
- **Eliminated namespace**: All types previously under `TSAccountProtectionSDK` namespace are now direct exports
- **Updated import syntax**: Imports now use named imports instead of mixed default + named imports
- **Simplified type references**: Types no longer require namespace prefixes

### API Changes

**Before:**
```js
import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';

await TSAccountProtectionSDKModule.initializeIOS(clientId);
await TSAccountProtectionSDKModule.triggerAction(TSAccountProtectionSDK.TSAction.login, options);
```

**After:**
```js
import { initializeIOS, triggerAction, TSAction } from 'react-native-ts-accountprotection';

await initializeIOS(clientId);
await triggerAction(TSAction.login, options);
```

### Benefits
- **Tree-shaking support**: Enables better bundle optimization and smaller app sizes
- **Cleaner imports**: More intuitive and concise import statements
- **Better IntelliSense**: Improved TypeScript auto-completion and code navigation
- **Modern standards**: Follows current React Native community best practices
- **Simplified usage**: No more verbose namespace references

### Migration
A complete migration guide is available in `MIGRATION_0.1.9-0.2.0.md` with step-by-step instructions for updating your existing code.

### Technical Details
- Removed wrapper class layer for direct native module access
- Streamlined type definitions without nested namespaces
- Maintained full API functionality while improving ergonomics

## Version 0.1.9

### Breaking Changes (iOS only)
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ dependencies {
// For < 0.71, this will be from the local maven repo
// For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
//noinspection GradleDynamicVersion
Comment thread
shachartransmit marked this conversation as resolved.
implementation("com.ts.sdk:accountprotection:2.2.4")
implementation("com.ts.sdk:accountprotection:2.2.5")
implementation "com.facebook.react:react-native:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
Expand Down
14 changes: 7 additions & 7 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- AccountProtection (0.0.8006):
- TSCoreSDK (~> 0.2.8000)
- AccountProtection (2.2.0):
- TSCoreSDK (~> 1.1.0)
- boost (1.83.0)
- DoubleConversion (1.1.6)
- FBLazyVector (0.73.5)
Expand Down Expand Up @@ -889,7 +889,7 @@ PODS:
- glog
- React-debug
- react-native-ts-accountprotection (0.1.9):
- AccountProtection (= 0.0.8006)
- AccountProtection (= 2.2.0)
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
Expand Down Expand Up @@ -1061,7 +1061,7 @@ PODS:
- React-logger (= 0.73.5)
- React-perflogger (= 0.73.5)
- SocketRocket (0.6.1)
- TSCoreSDK (0.2.8000)
- TSCoreSDK (1.1.2)
- Yoga (1.14.0)

DEPENDENCIES:
Expand Down Expand Up @@ -1228,7 +1228,7 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native/ReactCommon/yoga"

SPEC CHECKSUMS:
AccountProtection: 9e330dd72fe0eb1c0854d496994944cfdbca1251
AccountProtection: 32e1d95047bd7a183c6877a21b91dff2ed9223cb
boost: d3f49c53809116a5d38da093a8aa78bf551aed09
DoubleConversion: fea03f2699887d960129cc54bba7e52542b6f953
FBLazyVector: 56e0e498dbb513b96c40bac6284729ba4e62672d
Expand Down Expand Up @@ -1258,7 +1258,7 @@ SPEC CHECKSUMS:
React-jsinspector: 32db5e364bcae8fca8cdf8891830636275add0c5
React-logger: 4136cd22748f4275b04bf82f7b6853ba93b5e0e3
React-Mapbuffer: ee9b45b26e759a099a3e024df50b25af390ee998
react-native-ts-accountprotection: c8de4b1d1821ddc843b940fe96df4f8104fe9e52
react-native-ts-accountprotection: 5e32039e0dfe0d7c1f39ac4d398a9b6ad47d9b9d
React-nativeconfig: 1166714a4f7ea57a0df5c2cb44fbc70f98d580f9
React-NativeModulesApple: d4a50e6739e201716bc90178c143d019c8e09c36
React-perflogger: 0dd9f1725d55f8264b81efadd373fe1d9cca7dc2
Expand All @@ -1280,7 +1280,7 @@ SPEC CHECKSUMS:
React-utils: c89ba7cfbcc24a54c229928aa971a2539f5bdc21
ReactCommon: 878d3e9687f81294648a1d025b91ecde7e22179e
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
TSCoreSDK: 62d65a01ebde7c0bfe889582cbc6edffa3f09568
TSCoreSDK: 4f470f7de900589db07d9ff2967b5d733fe1be1d
Yoga: a716eea57d0d3430219c0a5a233e1e93ee931eb7

PODFILE CHECKSUM: f4bf8cd8d354e08c7c833a720648a16bd26f7e54
Expand Down
30 changes: 19 additions & 11 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

import { SafeAreaView, Keyboard, Alert, Platform } from 'react-native';

import TSAccountProtectionSDKModule, { TSAccountProtectionSDK } from 'react-native-ts-accountprotection';
import {

Check failure on line 5 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `Β·`
initializeIOS,
setUserId,
setLogLevel,
clearUser,

Check failure on line 9 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `Β·`
triggerAction,

Check failure on line 10 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `Β·`
TSAction,

Check failure on line 11 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `Β·`
type TSActionEventOptions

Check failure on line 12 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `Β·` with `,`
} from 'react-native-ts-accountprotection';
import MockServer from './mock-server';

import Login from './screens/login';
Expand All @@ -14,7 +22,7 @@
payerName: string;
payeeName: string;
amount: string;
}

Check failure on line 25 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `;`

export type State = {
currentScreen: AppScreen;
Expand All @@ -22,35 +30,35 @@
isLoading: boolean;
};

export type Props = {

Check failure on line 33 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Delete `⏎⏎`

};

const enum AppScreen {
Login = 'Login',

Check warning on line 38 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

'Login' is already declared in the upper scope on line 16 column 8
AuthenticatedUser = 'AuthenticatedUser'

Check failure on line 39 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Insert `,`

Check warning on line 39 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

'AuthenticatedUser' is already declared in the upper scope on line 17 column 10
}

export default class App extends React.Component<Props, State> {

Check failure on line 43 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎··private·mockServer·=·new·MockServer(config.baseUrl,·config.clientId,·config.secret` with `··private·mockServer·=·new·MockServer(⏎····config.baseUrl,⏎····config.clientId,⏎····config.secret⏎··`
private mockServer = new MockServer(config.baseUrl, config.clientId, config.secret);

constructor(props: Props) {
super(props);
this.state = {
currentScreen: AppScreen.Login,
errorMessage: "",

Check failure on line 50 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Replace `""` with `''`
isLoading: false
};
}

componentDidMount(): void {
this.onAppReady().catch(e => void e);

Check warning on line 56 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Expected 'undefined' and instead saw 'void'
}

render() {
return (
<SafeAreaView style={{ flex: 1 }}>

Check warning on line 61 in example/src/App.tsx

View workflow job for this annotation

GitHub Actions / lint

Inline style: { flex: 1 }
{
this.state.currentScreen === AppScreen.Login ? (
<Login onLogin={this.handleLogin} errorMessage={this.state.errorMessage} />
Expand All @@ -72,19 +80,19 @@
private onAppReady = async (): Promise<void> => {
// this is for iOS only, Android TSAccountProtectionSDK is initialized from application onCreate.
if (Platform.OS === 'ios') {
await TSAccountProtectionSDKModule.initializeIOS(config.clientId, null);
await initializeIOS(config.clientId, null);
}

const isLogEnabled = true;
await TSAccountProtectionSDKModule.setLogLevel(isLogEnabled);
await setLogLevel(isLogEnabled);
}

// Authentication

private handleLogin = async (username: string, password: string) => {
Keyboard.dismiss()
this.setState({ isLoading: true });
await TSAccountProtectionSDKModule.setUserId(username);
await setUserId(username);

setTimeout(async () => {
this.navigateToAuthenticatedUserScreen();
Expand All @@ -103,7 +111,7 @@
private onLogout = async () => {
Keyboard.dismiss()
this.setState({ isLoading: true });
await TSAccountProtectionSDKModule.clearUser();
await clearUser();
this.setState({
isLoading: false,
currentScreen: AppScreen.Login
Expand All @@ -117,8 +125,8 @@
this.setState({ isLoading: true });

try {
const triggerActionResponse = await TSAccountProtectionSDKModule.triggerAction(
`${TSAccountProtectionSDK.TSAction.transaction}`,
const triggerActionResponse = await triggerAction(
`${TSAction.transaction}`,
this.convertMoneyTransferDTOToEventOptions(requestDTO)
);

Expand All @@ -141,8 +149,8 @@
}

private handleTriggerActionLoginExample = async () => {
const triggerActionResponse = await TSAccountProtectionSDKModule.triggerAction(
TSAccountProtectionSDK.TSAction.login,
const triggerActionResponse = await triggerAction(
TSAction.login,
{
correlationId: "CORRELATION_ID",
claimUserId: "CLAIM_USER_ID",
Expand All @@ -154,8 +162,8 @@
console.log("Action Token: ", actionToken);
}

private convertMoneyTransferDTOToEventOptions = (requestDTO: MoneyTransferDTO): TSAccountProtectionSDK.TSActionEventOptions => {
const options: TSAccountProtectionSDK.TSActionEventOptions = {
private convertMoneyTransferDTOToEventOptions = (requestDTO: MoneyTransferDTO): TSActionEventOptions => {
const options: TSActionEventOptions = {
transactionData: {
amount: parseFloat(requestDTO.amount),
currency: 'USD',
Expand Down
Loading
Loading