Skip to content

Commit 8f5666d

Browse files
Merge pull request #134 from smallcase/development
Updating publish.yml to streamline the release process on npm
2 parents d620b31 + 33341a0 commit 8f5666d

16 files changed

Lines changed: 367 additions & 884 deletions

File tree

.github/workflows/publish.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,19 @@ name: publish to npm
22

33
on: [workflow_dispatch]
44

5+
permissions:
6+
id-token: write # Required for OIDC
7+
contents: read
8+
59
jobs:
610
build:
711
runs-on: ubuntu-latest
812
steps:
9-
- uses: actions/checkout@v2
13+
- uses: actions/checkout@v6
1014
# Setup .npmrc file to publish to npm
11-
- uses: actions/setup-node@v1
15+
- uses: actions/setup-node@v6
1216
with:
13-
node-version: "14.x"
17+
node-version: "25.x"
1418
registry-url: "https://registry.npmjs.org"
1519
- run: npm install
1620
- run: npm publish
17-
env:
18-
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
## [7.0.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v6.0.0...v7.0.0) (2026-01-05)
6+
7+
8+
### Features
9+
10+
* standardize smallplug response structure across iOS and Android ([0d82229](https://github.com/smallcase/react-native-smallcase-gateway/commit/0d82229b10fdd4eb67bd2866ca14b1972942e46d))
11+
512
### [6.0.1](https://github.com/smallcase/react-native-smallcase-gateway/compare/v6.0.0...v6.0.1) (2025-12-06)
613

714
## [6.0.0](https://github.com/smallcase/react-native-smallcase-gateway/compare/v5.2.0...v6.0.0) (2025-11-20)

android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def kotlin_version = getExtOrDefault('kotlinVersion')
149149
dependencies {
150150
//noinspection GradleDynamicVersion
151151
implementation 'com.facebook.react:react-native:+' // From node_modules
152-
implementation 'com.smallcase.gateway:sdk:5.0.1'
152+
implementation 'com.smallcase.gateway:sdk:6.0.0'
153153
implementation 'com.smallcase.loans:sdk:4.0.0'
154154
implementation "androidx.core:core-ktx:1.3.1"
155155
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"

android/src/main/java/com/reactnativesmallcasegateway/SmallcaseGatewayModule.kt

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,8 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
161161
fun launchSmallplug(targetEndpoint: String, params: String, promise: Promise) {
162162

163163
SmallcaseGatewaySdk.launchSmallPlug(currentActivity!!, SmallplugData(targetEndpoint, params), object : SmallPlugResponseListener {
164-
override fun onFailure(errorCode: Int, errorMessage: String) {
164+
override fun onFailure(errorCode: Int, errorMessage: String) {
165165
val err = createErrorJSON(errorCode, errorMessage, null)
166-
167166
promise.reject("error", err)
168167
}
169168

@@ -469,15 +468,36 @@ class SmallcaseGatewayModule(reactContext: ReactApplicationContext) : ReactConte
469468
writableMap.putBoolean("success", result.success)
470469
writableMap.putString("smallcaseAuthToken", result.smallcaseAuthToken)
471470

471+
val dataMap = Arguments.createMap()
472+
userInfoToWritableMap(result.userInfo)?.let {
473+
dataMap.putMap("userInfo", it)
474+
}
475+
476+
if (dataMap.keySetIterator().hasNextKey()) {
477+
writableMap.putMap("data", dataMap)
478+
}
479+
472480
return writableMap
473481
}
474482

475-
private fun createErrorJSON(errorCode: Int?, errorMessage: String?, data: String?): WritableMap {
483+
private fun userInfoToWritableMap(userInfo: UserInfo?): WritableMap? {
484+
if (userInfo == null) return null
485+
486+
val map = Arguments.createMap()
487+
map.putString("number", userInfo.number)
488+
map.putString("countryCode", userInfo.countryCode)
489+
return map
490+
}
491+
492+
private fun createErrorJSON(errorCode: Int?, errorMessage: String?, data: Any?): WritableMap {
476493
val errObj = Arguments.createMap()
477494

478495
errorCode?.let { errObj.putInt("errorCode", it) }
479496
errorMessage?.let { errObj.putString("errorMessage", it) }
480-
data?.let { errObj.putString("data", it) }
497+
when (data) {
498+
is String -> errObj.putString("data", data)
499+
is WritableMap -> errObj.putMap("data", data)
500+
}
481501

482502
return errObj
483503
}

ios/SmallcaseGateway.m

Lines changed: 60 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -333,40 +333,51 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
333333

334334
[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData completion:^(id smallplugResponse, NSError * error) {
335335

336-
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
337-
338336
if (error != nil) {
339337
NSLog(@"%@", error.domain);
340338
double delayInSeconds = 0.5;
341339
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
342340
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
343-
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
344-
[responseDict setValue:[NSNumber numberWithBool:false] forKey:@"success"];
345-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
346-
[responseDict setValue:error.domain forKey:@"error"];
347-
348-
resolve(responseDict);
349-
return;
341+
NSMutableDictionary *errorDict = [[NSMutableDictionary alloc] init];
342+
[errorDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
343+
[errorDict setValue:error.domain forKey:@"errorMessage"];
344+
345+
reject(@"error", error.domain, error);
350346
});
351347
} else {
352-
353-
if ([smallplugResponse isKindOfClass: [NSString class]]) {
354-
NSLog(@"%@", smallplugResponse);
355-
356-
[responseDict setValue:[NSNumber numberWithBool: true] forKey:@"success"];
357-
[responseDict setValue:smallplugResponse forKey:@"smallcaseAuthToken"];
348+
if ([smallplugResponse isKindOfClass:[SmallPlugResult class]]) {
349+
SmallPlugResult *result = (SmallPlugResult *)smallplugResponse;
350+
351+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
352+
[responseDict setValue:[NSNumber numberWithBool:true] forKey:@"success"];
353+
354+
if (result.smallcaseAuthToken) {
355+
[responseDict setValue:result.smallcaseAuthToken forKey:@"smallcaseAuthToken"];
356+
}
357+
358+
// Add userInfo inside data object if available
359+
if (result.userInfo) {
360+
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
361+
NSMutableDictionary *userInfoDict = [[NSMutableDictionary alloc] init];
362+
363+
if (result.userInfo.number) {
364+
[userInfoDict setValue:result.userInfo.number forKey:@"number"];
365+
}
366+
if (result.userInfo.countryCode) {
367+
[userInfoDict setValue:result.userInfo.countryCode forKey:@"countryCode"];
368+
}
369+
370+
[dataDict setValue:userInfoDict forKey:@"userInfo"];
371+
[responseDict setValue:dataDict forKey:@"data"];
372+
}
358373

359374
double delayInSeconds = 0.5;
360375
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
361376
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
362-
363377
resolve(responseDict);
364-
return;
365-
366378
});
367379
}
368380
}
369-
370381
}];
371382
});
372383
}
@@ -405,40 +416,51 @@ @interface RCT_EXTERN_MODULE(SmallcaseGateway, NSObject)
405416

406417
[SCGateway.shared launchSmallPlugWithPresentingController:[[[UIApplication sharedApplication] keyWindow] rootViewController] smallplugData:smallplugData smallplugUiConfig:smallplugUiConfig completion:^(id smallplugResponse, NSError * error) {
407418

408-
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
409-
410419
if (error != nil) {
411420
NSLog(@"%@", error.domain);
412421
double delayInSeconds = 0.5;
413422
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
414423
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
415-
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
416-
[responseDict setValue:[NSNumber numberWithBool:false] forKey:@"success"];
417-
[responseDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
418-
[responseDict setValue:error.domain forKey:@"error"];
419-
420-
resolve(responseDict);
421-
return;
424+
NSMutableDictionary *errorDict = [[NSMutableDictionary alloc] init];
425+
[errorDict setValue:[NSNumber numberWithInteger:error.code] forKey:@"errorCode"];
426+
[errorDict setValue:error.domain forKey:@"errorMessage"];
427+
428+
reject(@"error", error.domain, error);
422429
});
423430
} else {
424-
425-
if ([smallplugResponse isKindOfClass: [NSString class]]) {
426-
NSLog(@"%@", smallplugResponse);
427-
428-
[responseDict setValue:[NSNumber numberWithBool: true] forKey:@"success"];
429-
[responseDict setValue:smallplugResponse forKey:@"smallcaseAuthToken"];
431+
if ([smallplugResponse isKindOfClass:[SmallPlugResult class]]) {
432+
SmallPlugResult *result = (SmallPlugResult *)smallplugResponse;
433+
434+
NSMutableDictionary *responseDict = [[NSMutableDictionary alloc] init];
435+
[responseDict setValue:[NSNumber numberWithBool:true] forKey:@"success"];
436+
437+
if (result.smallcaseAuthToken) {
438+
[responseDict setValue:result.smallcaseAuthToken forKey:@"smallcaseAuthToken"];
439+
}
440+
441+
// Add userInfo inside data object if available
442+
if (result.userInfo) {
443+
NSMutableDictionary *dataDict = [[NSMutableDictionary alloc] init];
444+
NSMutableDictionary *userInfoDict = [[NSMutableDictionary alloc] init];
445+
446+
if (result.userInfo.number) {
447+
[userInfoDict setValue:result.userInfo.number forKey:@"number"];
448+
}
449+
if (result.userInfo.countryCode) {
450+
[userInfoDict setValue:result.userInfo.countryCode forKey:@"countryCode"];
451+
}
452+
453+
[dataDict setValue:userInfoDict forKey:@"userInfo"];
454+
[responseDict setValue:dataDict forKey:@"data"];
455+
}
430456

431457
double delayInSeconds = 0.5;
432458
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
433459
dispatch_after(popTime, dispatch_get_main_queue(), ^(void) {
434-
435460
resolve(responseDict);
436-
return;
437-
438461
});
439462
}
440463
}
441-
442464
}];
443465
});
444466
}

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "react-native-smallcase-gateway",
33
"title": "React Native Smallcase Gateway",
4-
"version": "6.0.1",
4+
"version": "7.0.0",
55
"description": "smallcase gateway bindings for react native",
66
"main": "src/index.js",
77
"files": [
@@ -67,8 +67,6 @@
6767
"jest": "^28.1.1",
6868
"pod-install": "^0.1.0",
6969
"prettier": "^2.0.5",
70-
"react": "17.0.2",
71-
"react-native": "0.68.2",
7270
"react-native-builder-bob": "^0.18.3",
7371
"release-it": "^15.0.0",
7472
"standard-version": "^9.5.0",

react-native-smallcase-gateway.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ Pod::Spec.new do |s|
3333
s.dependency "ReactCommon/turbomodule/core"
3434
end
3535

36-
s.dependency 'SCGateway', '6.1.1'
36+
s.dependency 'SCGateway', '7.0.0'
3737
s.dependency 'SCLoans', '6.0.2'
3838
end

smart_investing_react_native/android/gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
3232
# your application. You should enable this flag either if you want
3333
# to write custom TurboModules/Fabric components OR use libraries that
3434
# are providing them.
35-
newArchEnabled=true
35+
newArchEnabled=false
36+
fabricEnabled=false
3637

3738
# Use this property to enable or disable the Hermes JS engine.
3839
# If set to false, you will be using JSC instead.

smart_investing_react_native/app/apis/Functions.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,14 +422,35 @@ interface UIConfig {
422422
backIconOpacity: number;
423423
}
424424

425+
export interface UserInfo {
426+
phoneNumber: string;
427+
phoneCountryCode: string;
428+
}
429+
430+
export interface SmallplugRes {
431+
success: boolean;
432+
smallcaseAuthToken: string;
433+
data?: {
434+
userInfo?: UserInfo;
435+
};
436+
}
437+
438+
export interface SmallplugError {
439+
errorCode: number;
440+
errorMessage: string;
441+
data?: {
442+
userInfo?: UserInfo;
443+
};
444+
}
445+
425446
async function launchSmallPlug(
426447
targetEndpoint: any,
427448
params: any,
428449
uiConfig: UIConfig,
429-
) {
450+
): Promise<SmallplugRes> {
430451
try {
431452
console.log(`launchSmallPlug start ${JSON.stringify(uiConfig)}`);
432-
const res = await SmallcaseGateway.launchSmallplugWithBranding(
453+
const res: any = await SmallcaseGateway.launchSmallplugWithBranding(
433454
targetEndpoint,
434455
params,
435456
uiConfig.headerColor ?? '',
@@ -438,12 +459,14 @@ async function launchSmallPlug(
438459
uiConfig.backIconOpacity,
439460
);
440461
console.log(`launch dm res -> ${JSON.stringify(res)}`);
441-
alert('Launch Smallplug Success', JSON.stringify(res));
462+
await alert('Launch Smallplug Success', JSON.stringify(res));
463+
return res;
442464
} catch (error) {
443465
console.log(
444466
'Launch Smallplug error stringified - ' + JSON.stringify(error),
445467
);
446-
alert('Launch Smallplug Error', getErrorString(error));
468+
await alert('Launch Smallplug Error', getErrorString(error));
469+
throw error;
447470
}
448471
}
449472

0 commit comments

Comments
 (0)