api-gateway-react-native 0.1.0
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/ApiGatwayReactNativeSdk.podspec +36 -0
- package/LICENSE +20 -0
- package/README.md +159 -0
- package/android/build.gradle +84 -0
- package/android/gradle.properties +5 -0
- package/android/libs/apiGateway-release.aar +0 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/apigatwayreactnativesdk/ApiGatwayReactNativeSdkModule.kt +32 -0
- package/android/src/main/java/com/apigatwayreactnativesdk/ApiGatwayReactNativeSdkPackage.kt +19 -0
- package/ios/ApiGatewayReactNativeSdk-Bridging-Header.h +3 -0
- package/ios/ApiGatewayWrapper.swift +26 -0
- package/ios/ApiGatwayReactNativeSdk.h +4 -0
- package/ios/ApiGatwayReactNativeSdk.mm +29 -0
- package/ios/TNApiGetwaySDK.xcframework/Info.plist +44 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Headers/TNApiGatewayCrypto.h +34 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Headers/TNApiGetwaySDK.h +13 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Info.plist +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios.abi.json +1419 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios.private.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios.swiftdoc +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Modules/module.modulemap +6 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/TNApiGetwaySDK +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/_CodeSignature/CodeResources +201 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Headers/TNApiGatewayCrypto.h +34 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Headers/TNApiGetwaySDK.h +13 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Info.plist +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios-simulator.abi.json +1419 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios-simulator.private.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/arm64-apple-ios-simulator.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/x86_64-apple-ios-simulator.abi.json +1419 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/x86_64-apple-ios-simulator.private.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/x86_64-apple-ios-simulator.swiftdoc +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/TNApiGetwaySDK.swiftmodule/x86_64-apple-ios-simulator.swiftinterface +57 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/Modules/module.modulemap +6 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/TNApiGetwaySDK +0 -0
- package/ios/TNApiGetwaySDK.xcframework/ios-arm64_x86_64-simulator/TNApiGetwaySDK.framework/_CodeSignature/CodeResources +256 -0
- package/lib/module/NativeApiGatwayReactNativeSdk.js +14 -0
- package/lib/module/NativeApiGatwayReactNativeSdk.js.map +1 -0
- package/lib/module/index.js +16 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NativeApiGatwayReactNativeSdk.d.ts +6 -0
- package/lib/typescript/src/NativeApiGatwayReactNativeSdk.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +9 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +169 -0
- package/src/NativeApiGatwayReactNativeSdk.ts +26 -0
- package/src/index.tsx +13 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = "ApiGatwayReactNativeSdk"
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = "https://github.com/technonext/api-gatway-react-native-sdk"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
s.authors = { "technonext" => "technonext@example.com" }
|
|
12
|
+
s.platforms = { :ios => "11.0" }
|
|
13
|
+
s.source = { :git => "https://github.com/technonext/api-gatway-react-native-sdk.git", :tag => "#{s.version}" }
|
|
14
|
+
|
|
15
|
+
# Include Objective-C/Objective-C++ and Swift files
|
|
16
|
+
s.source_files = "ios/*.{h,m,mm,swift}"
|
|
17
|
+
s.exclude_files = "ios/ApiGatewayModule.{m,swift}", "ios/ApiGatewayReactNativeSdk-Bridging-Header.h", "ios/ApiGatewayModule.m"
|
|
18
|
+
|
|
19
|
+
# Vendored XCFramework
|
|
20
|
+
s.vendored_frameworks = "ios/TNApiGetwaySDK.xcframework"
|
|
21
|
+
|
|
22
|
+
# Swift version
|
|
23
|
+
s.swift_version = "5.0"
|
|
24
|
+
|
|
25
|
+
s.frameworks = "Foundation"
|
|
26
|
+
s.pod_target_xcconfig = {
|
|
27
|
+
'OTHER_LDFLAGS' => '-framework TNApiGetwaySDK',
|
|
28
|
+
'CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES' => 'YES',
|
|
29
|
+
'DEFINES_MODULE' => 'YES'
|
|
30
|
+
}
|
|
31
|
+
s.user_target_xcconfig = {
|
|
32
|
+
'OTHER_LDFLAGS' => '-framework TNApiGetwaySDK'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
s.dependency "React-Core"
|
|
36
|
+
end
|
package/LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mapnests
|
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
5
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
6
|
+
in the Software without restriction, including without limitation the rights
|
|
7
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
8
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
9
|
+
furnished to do so, subject to the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be included in all
|
|
12
|
+
copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
17
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
18
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
19
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
20
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# api-gateway-react-native
|
|
2
|
+
|
|
3
|
+
## Changelog (v1.0.0)
|
|
4
|
+
- Initial integration of the API Gateway SDK.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```sh
|
|
9
|
+
npm install api-gateway-react-native
|
|
10
|
+
```
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```js
|
|
14
|
+
import ApiGatway from 'api-gateway-react-native';
|
|
15
|
+
|
|
16
|
+
const nativeHeaders = await ApiGatway.getHeaders();
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
nativeHeaders retrun neesssary header of your applicaiotion. add your own interfaecotor or http request header or RTK or whatable.
|
|
20
|
+
|
|
21
|
+
Example with RTK quaary with Merge headers into request
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
|
|
25
|
+
import { createApi } from '@reduxjs/toolkit/query/react';
|
|
26
|
+
import { fetchBaseQuery } from '@reduxjs/toolkit/query/react';
|
|
27
|
+
import ApiGatway from 'api-gateway-react-native';
|
|
28
|
+
|
|
29
|
+
const baseQueryWithNativeHeaders = async (args: any, api: any, extraOptions: any) => {
|
|
30
|
+
const baseQuery = fetchBaseQuery({
|
|
31
|
+
baseUrl: 'http://example.com', //
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
let nativeHeaders: Record<string, string> = {};
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
nativeHeaders = await ApiGatway.getHeaders();
|
|
38
|
+
} catch (e: any) {
|
|
39
|
+
console.warn('Failed to get native headers:', e.message || e);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Merge headers into request
|
|
43
|
+
const queryArgs =
|
|
44
|
+
typeof args === 'string'
|
|
45
|
+
? { url: args, headers: nativeHeaders }
|
|
46
|
+
: { ...args, headers: { ...args.headers, ...nativeHeaders } };
|
|
47
|
+
|
|
48
|
+
return baseQuery(queryArgs, api, extraOptions);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const api = createApi({
|
|
52
|
+
reducerPath: 'api',
|
|
53
|
+
baseQuery: baseQueryWithNativeHeaders,
|
|
54
|
+
endpoints: (builder) => ({
|
|
55
|
+
getAuthCasbinTest: builder.query<any, void>({
|
|
56
|
+
query: () => '/exampleAPIEndpoint', // GET request
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const { useGetAuthCasbinTestQuery } = api;
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
## Onboarding Process
|
|
68
|
+
|
|
69
|
+
1. Send email mentioning all of your package names (com.example.debug, com.example.release etc) and send to `apigw@technonext.com` to get `bind-client-config.json`.
|
|
70
|
+
2. Place `bind-client-config.json` in the **root directory** of your project.
|
|
71
|
+
|
|
72
|
+
## Project Setup Android
|
|
73
|
+
|
|
74
|
+
### Root `build.gradle.kts`
|
|
75
|
+
Add the Mapnests `config-loader` plugin.
|
|
76
|
+
|
|
77
|
+
Plugin: `com.mapnests.config-loader:com.mapnests.config-loader.gradle.plugin:4.0.0`
|
|
78
|
+
|
|
79
|
+
``` groovy
|
|
80
|
+
buildscript {
|
|
81
|
+
repositories {
|
|
82
|
+
mavenLocal()
|
|
83
|
+
gradlePluginPortal()
|
|
84
|
+
google()
|
|
85
|
+
mavenCentral()
|
|
86
|
+
}
|
|
87
|
+
dependencies {
|
|
88
|
+
classpath("com.android.tools.build:gradle:8.13.1")
|
|
89
|
+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.21")
|
|
90
|
+
classpath("com.mapnests.config-loader:com.mapnests.config-loader.gradle.plugin:4.0.0")
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Module build.gradle
|
|
96
|
+
|
|
97
|
+
Set Java and Kotlin compatibility:
|
|
98
|
+
|
|
99
|
+
```groovy
|
|
100
|
+
plugins {
|
|
101
|
+
// other gradle plugins
|
|
102
|
+
id("com.mapnests.config-loader")
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
compileOptions {
|
|
106
|
+
sourceCompatibility = JavaVersion.VERSION_17
|
|
107
|
+
targetCompatibility = JavaVersion.VERSION_17
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
kotlin {
|
|
111
|
+
compilerOptions {
|
|
112
|
+
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
## Project Setup IOS
|
|
119
|
+
|
|
120
|
+
1. Drag and drop the `TNApiGetwaySDK.xcframework` into your project’s **Project Navigator** (e.g., into a `Frameworks` group).
|
|
121
|
+
2. Select your project in Xcode → **Target** → **General** tab.
|
|
122
|
+
3. Scroll down to **Frameworks, Libraries, and Embedded Content**.
|
|
123
|
+
4. Click the **+** button → Add `TNApiGetwaySDK.xcframework`.
|
|
124
|
+
5. Set **Embed** to **Embed & Sign**.
|
|
125
|
+
|
|
126
|
+
### Root `add TNApiGetwaySDKConfigFile under your Info.plist`
|
|
127
|
+
|
|
128
|
+
```xml
|
|
129
|
+
|
|
130
|
+
<dict>
|
|
131
|
+
<key>TNApiGetwaySDKConfigFile</key>
|
|
132
|
+
<string>bind-client-config.json</string>
|
|
133
|
+
</dict>
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
#Add your URLProtocol class to URLSession
|
|
137
|
+
|
|
138
|
+
```swift
|
|
139
|
+
|
|
140
|
+
let config = URLSessionConfiguration.default
|
|
141
|
+
config.protocolClasses = [ClientNetworkProtocol.self] // Inject framework headers
|
|
142
|
+
return URLSession(configuration: config)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Developer Notes
|
|
147
|
+
- Keep package names consistent between JSON and Gradle.
|
|
148
|
+
- HTTPS is preferred. Only enable HTTP with cleartext traffic if necessary.
|
|
149
|
+
- If you receive a 401 error, recheck the app package name and make sure you are using the correct bind-client-config.json file.
|
|
150
|
+
|
|
151
|
+
## Common Fixes
|
|
152
|
+
-
|
|
153
|
+
- Check developers note
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Support
|
|
158
|
+
|
|
159
|
+
For issues or feature requests contact us through email: `apigw@technonext.com`
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
buildscript {
|
|
2
|
+
ext.getExtOrDefault = {name ->
|
|
3
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ApiGatwayReactNativeSdk_' + name]
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
repositories {
|
|
7
|
+
mavenLocal()
|
|
8
|
+
gradlePluginPortal()
|
|
9
|
+
google()
|
|
10
|
+
mavenCentral()
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
dependencies {
|
|
14
|
+
classpath "com.android.tools.build:gradle:8.7.2"
|
|
15
|
+
// noinspection DifferentKotlinGradleVersion
|
|
16
|
+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
|
|
17
|
+
classpath("com.mapnests.config-loader:com.mapnests.config-loader.gradle.plugin:4.0.0")
|
|
18
|
+
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
apply plugin: "com.android.library"
|
|
24
|
+
apply plugin: "kotlin-android"
|
|
25
|
+
|
|
26
|
+
apply plugin: "com.facebook.react"
|
|
27
|
+
apply plugin: "com.mapnests.config-loader"
|
|
28
|
+
|
|
29
|
+
def getExtOrIntegerDefault(name) {
|
|
30
|
+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["ApiGatwayReactNativeSdk_" + name]).toInteger()
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
android {
|
|
34
|
+
namespace "com.apigatwayreactnativesdk"
|
|
35
|
+
|
|
36
|
+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
37
|
+
|
|
38
|
+
defaultConfig {
|
|
39
|
+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
40
|
+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
buildFeatures {
|
|
44
|
+
buildConfig true
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
buildTypes {
|
|
48
|
+
release {
|
|
49
|
+
minifyEnabled false
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
lintOptions {
|
|
54
|
+
disable "GradleCompatible"
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
compileOptions {
|
|
58
|
+
sourceCompatibility JavaVersion.VERSION_1_8
|
|
59
|
+
targetCompatibility JavaVersion.VERSION_1_8
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
sourceSets {
|
|
63
|
+
main {
|
|
64
|
+
java.srcDirs += [
|
|
65
|
+
"generated/java",
|
|
66
|
+
"generated/jni"
|
|
67
|
+
]
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
repositories {
|
|
73
|
+
mavenCentral()
|
|
74
|
+
google()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
78
|
+
|
|
79
|
+
dependencies {
|
|
80
|
+
implementation "com.facebook.react:react-android"
|
|
81
|
+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
82
|
+
|
|
83
|
+
implementation files('libs/apiGateway-release.aar')
|
|
84
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.apigatwayreactnativesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.*
|
|
4
|
+
import com.technonext.network.ApiGatewayHeaderProvider
|
|
5
|
+
|
|
6
|
+
class ApiGatwayReactNativeSdkModule(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
7
|
+
|
|
8
|
+
companion object {
|
|
9
|
+
init {
|
|
10
|
+
System.loadLibrary("TNApiGatewaySDK")
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun getName(): String {
|
|
15
|
+
return "ApiGatwayReactNativeSdk"
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
@ReactMethod
|
|
19
|
+
fun getHeaders(promise: Promise) {
|
|
20
|
+
try {
|
|
21
|
+
val headerProvider = ApiGatewayHeaderProvider(reactApplicationContext)
|
|
22
|
+
val headers = headerProvider.headers
|
|
23
|
+
val writableMap = Arguments.createMap()
|
|
24
|
+
for ((key, value) in headers) {
|
|
25
|
+
writableMap.putString(key, value)
|
|
26
|
+
}
|
|
27
|
+
promise.resolve(writableMap)
|
|
28
|
+
} catch (e: Exception) {
|
|
29
|
+
promise.reject("ERR_UNEXPECTED_EXCEPTION", e.message, e)
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package com.apigatwayreactnativesdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.ReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
7
|
+
import java.util.Collections
|
|
8
|
+
|
|
9
|
+
class ApiGatwayReactNativeSdkPackage : ReactPackage {
|
|
10
|
+
override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
|
|
11
|
+
return emptyList()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
|
|
15
|
+
val modules = mutableListOf<NativeModule>()
|
|
16
|
+
modules.add(ApiGatwayReactNativeSdkModule(reactContext))
|
|
17
|
+
return modules
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//
|
|
2
|
+
// ApiGatewayWrapper.swift
|
|
3
|
+
// api-gatway-react-native-sdk
|
|
4
|
+
//
|
|
5
|
+
// Swift wrapper to bridge TNApiGetwaySDK framework to Objective-C
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
import Foundation
|
|
9
|
+
import TNApiGetwaySDK
|
|
10
|
+
|
|
11
|
+
@objc(ApiGatewayWrapper)
|
|
12
|
+
public class ApiGatewayWrapper: NSObject {
|
|
13
|
+
|
|
14
|
+
@objc public static let shared = ApiGatewayWrapper()
|
|
15
|
+
|
|
16
|
+
private override init() {
|
|
17
|
+
super.init()
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@objc public func getHeaders() -> [String: String] {
|
|
21
|
+
// Use the ApiGatewayHeaderProvider from the framework
|
|
22
|
+
let headerProvider = ApiGatewayHeaderProvider.shared
|
|
23
|
+
let headers = headerProvider.getHeaders()
|
|
24
|
+
return headers
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#import "ApiGatwayReactNativeSdk.h"
|
|
2
|
+
|
|
3
|
+
// Forward declare the Swift class
|
|
4
|
+
// The actual implementation is in ApiGatewayWrapper.swift
|
|
5
|
+
@interface ApiGatewayWrapper : NSObject
|
|
6
|
+
+ (ApiGatewayWrapper * _Nonnull)shared;
|
|
7
|
+
- (NSDictionary<NSString *, NSString *> * _Nonnull)getHeaders;
|
|
8
|
+
@end
|
|
9
|
+
|
|
10
|
+
@implementation ApiGatwayReactNativeSdk
|
|
11
|
+
|
|
12
|
+
RCT_EXPORT_MODULE()
|
|
13
|
+
|
|
14
|
+
RCT_REMAP_METHOD(getHeaders,
|
|
15
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
16
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
17
|
+
{
|
|
18
|
+
@try {
|
|
19
|
+
// Use our Swift wrapper to access the framework
|
|
20
|
+
ApiGatewayWrapper *wrapper = [ApiGatewayWrapper shared];
|
|
21
|
+
NSDictionary<NSString *, NSString *> *headers = [wrapper getHeaders];
|
|
22
|
+
resolve(headers);
|
|
23
|
+
} @catch (NSException *exception) {
|
|
24
|
+
reject(@"ERR_UNEXPECTED_EXCEPTION", exception.reason, nil);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@end
|
|
29
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>TNApiGetwaySDK.framework/TNApiGetwaySDK</string>
|
|
10
|
+
<key>LibraryIdentifier</key>
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
|
+
<key>LibraryPath</key>
|
|
13
|
+
<string>TNApiGetwaySDK.framework</string>
|
|
14
|
+
<key>SupportedArchitectures</key>
|
|
15
|
+
<array>
|
|
16
|
+
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
18
|
+
</array>
|
|
19
|
+
<key>SupportedPlatform</key>
|
|
20
|
+
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
23
|
+
</dict>
|
|
24
|
+
<dict>
|
|
25
|
+
<key>BinaryPath</key>
|
|
26
|
+
<string>TNApiGetwaySDK.framework/TNApiGetwaySDK</string>
|
|
27
|
+
<key>LibraryIdentifier</key>
|
|
28
|
+
<string>ios-arm64</string>
|
|
29
|
+
<key>LibraryPath</key>
|
|
30
|
+
<string>TNApiGetwaySDK.framework</string>
|
|
31
|
+
<key>SupportedArchitectures</key>
|
|
32
|
+
<array>
|
|
33
|
+
<string>arm64</string>
|
|
34
|
+
</array>
|
|
35
|
+
<key>SupportedPlatform</key>
|
|
36
|
+
<string>ios</string>
|
|
37
|
+
</dict>
|
|
38
|
+
</array>
|
|
39
|
+
<key>CFBundlePackageType</key>
|
|
40
|
+
<string>XFWK</string>
|
|
41
|
+
<key>XCFrameworkFormatVersion</key>
|
|
42
|
+
<string>1.0</string>
|
|
43
|
+
</dict>
|
|
44
|
+
</plist>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TNApiGatewayCrypto.h
|
|
3
|
+
// TNMapSDK
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
#import <Foundation/Foundation.h>
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface TNApiGatewayCrypto : NSObject
|
|
11
|
+
|
|
12
|
+
/// Equivalent to nativeGenerateAESKey()
|
|
13
|
+
+ (NSString *)generateAESKey;
|
|
14
|
+
|
|
15
|
+
/// Equivalent to nativeMethod()
|
|
16
|
+
+ (NSDictionary<NSString *, NSString *> *)encryptPayloadForHeaders:(NSString *)jsonString
|
|
17
|
+
publicKeyPEM:(NSString *)publicKeyPEM
|
|
18
|
+
dataIdentity:(NSString *)dataIdentity
|
|
19
|
+
clientIdentity:(NSString *)clientIdentity;
|
|
20
|
+
|
|
21
|
+
/// Equivalent to nativeDataIdentityMethod()
|
|
22
|
+
+ (NSString *)encryptAESKey:(NSString *)aesKeyBase64
|
|
23
|
+
publicKeyPEM:(NSString *)publicKeyPEM;
|
|
24
|
+
|
|
25
|
+
/// Equivalent to nativeClientIdentityMethod()
|
|
26
|
+
+ (NSString *)encryptClientPayload:(NSString *)jsonString
|
|
27
|
+
aesKeyBase64:(NSString *)aesKeyBase64;
|
|
28
|
+
|
|
29
|
+
/// Equivalent to nativeGetServerTime()
|
|
30
|
+
+ (NSTimeInterval)fetchServerTime;
|
|
31
|
+
|
|
32
|
+
@end
|
|
33
|
+
|
|
34
|
+
NS_ASSUME_NONNULL_END
|
package/ios/TNApiGetwaySDK.xcframework/ios-arm64/TNApiGetwaySDK.framework/Headers/TNApiGetwaySDK.h
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//
|
|
2
|
+
// TNApiGetwaySDK.h
|
|
3
|
+
// TNApiGetwaySDK
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
//#import <Foundation/Foundation.h>
|
|
7
|
+
|
|
8
|
+
// Public headers of your framework:
|
|
9
|
+
#import <TNApiGetwaySDK/TNApiGatewayCrypto.h>
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
// FOUNDATION_EXPORT double TNApiGetwaySDKVersionNumber;
|
|
13
|
+
// FOUNDATION_EXPORT const unsigned char TNApiGetwaySDKVersionString[];
|