@altcraft/react-native-sdk 0.0.1
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/LICENSE +20 -0
- package/README.md +46 -0
- package/Sdk.podspec +48 -0
- package/android/build.gradle +78 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +1242 -0
- package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +33 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +27 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +32 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +21 -0
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +53 -0
- package/ios/Sdk.h +19 -0
- package/ios/Sdk.mm +1112 -0
- package/ios/SdkModule.swift +888 -0
- package/ios/protocols/RNAPNSProvider.swift +15 -0
- package/ios/protocols/RNFCMProvider.swift +24 -0
- package/ios/protocols/RNHMSProvider.swift +24 -0
- package/ios/protocols/RNJWTProvider.swift +15 -0
- package/lib/module/NativeSdk.js +13 -0
- package/lib/module/NativeSdk.js.map +1 -0
- package/lib/module/index.js +561 -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/NativeSdk.d.ts +114 -0
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +391 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +128 -0
- package/react-native.config.js +10 -0
- package/src/NativeSdk.ts +171 -0
- package/src/index.tsx +670 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
package com.altcraft.sdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.BaseReactPackage
|
|
4
|
+
import com.facebook.react.bridge.NativeModule
|
|
5
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.module.model.ReactModuleInfo
|
|
7
|
+
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
|
+
import java.util.HashMap
|
|
9
|
+
|
|
10
|
+
class SdkPackage : BaseReactPackage() {
|
|
11
|
+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
+
return if (name == SdkModule.NAME) {
|
|
13
|
+
SdkModule(reactContext)
|
|
14
|
+
} else {
|
|
15
|
+
null
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
20
|
+
return ReactModuleInfoProvider {
|
|
21
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
22
|
+
moduleInfos[SdkModule.NAME] = ReactModuleInfo(
|
|
23
|
+
SdkModule.NAME,
|
|
24
|
+
SdkModule.NAME,
|
|
25
|
+
false, // canOverrideExistingModule
|
|
26
|
+
false, // needsEagerInit
|
|
27
|
+
false, // isCxxModule
|
|
28
|
+
true // isTurboModule
|
|
29
|
+
)
|
|
30
|
+
moduleInfos
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
package com.altcraft.sdk.rn.providers
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Keep
|
|
4
|
+
import com.altcraft.sdk.interfaces.FCMInterface
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
@Keep
|
|
8
|
+
object RnFCMProvider : FCMInterface {
|
|
9
|
+
|
|
10
|
+
@Volatile
|
|
11
|
+
private var token: String? = null
|
|
12
|
+
|
|
13
|
+
override suspend fun getToken(): String? = token
|
|
14
|
+
|
|
15
|
+
override suspend fun deleteToken(completion: (Boolean) -> Unit) {
|
|
16
|
+
token = null
|
|
17
|
+
completion(true)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
fun setToken(newToken: String?) {
|
|
21
|
+
token = newToken
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
fun clear() {
|
|
25
|
+
token = null
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
package com.altcraft.sdk.rn.providers
|
|
2
|
+
|
|
3
|
+
// Created by Andrey Pogodin.
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2025 Altcraft. All rights reserved.
|
|
6
|
+
|
|
7
|
+
import android.content.Context
|
|
8
|
+
import androidx.annotation.Keep
|
|
9
|
+
import com.altcraft.sdk.interfaces.HMSInterface
|
|
10
|
+
|
|
11
|
+
@Keep
|
|
12
|
+
object RnHMSProvider : HMSInterface {
|
|
13
|
+
|
|
14
|
+
@Volatile
|
|
15
|
+
private var token: String? = null
|
|
16
|
+
|
|
17
|
+
override suspend fun getToken(context: Context): String? = token
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
override suspend fun deleteToken(context: Context, complete: (Boolean) -> Unit) {
|
|
21
|
+
token = null
|
|
22
|
+
complete(true)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fun setToken(newToken: String?) {
|
|
26
|
+
token = newToken
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fun clear() {
|
|
30
|
+
token = null
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package com.altcraft.sdk.rn.providers
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Keep
|
|
4
|
+
import com.altcraft.sdk.interfaces.JWTInterface
|
|
5
|
+
|
|
6
|
+
@Keep
|
|
7
|
+
object RnJWTProvider : JWTInterface {
|
|
8
|
+
|
|
9
|
+
@Volatile
|
|
10
|
+
private var jwt: String? = null
|
|
11
|
+
|
|
12
|
+
override fun getJWT(): String? = jwt
|
|
13
|
+
|
|
14
|
+
fun setToken(newToken: String?) {
|
|
15
|
+
jwt = newToken
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
fun clear() {
|
|
19
|
+
jwt = null
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
package com.altcraft.sdk.rn.providers
|
|
2
|
+
|
|
3
|
+
// Created by Andrey Pogodin.
|
|
4
|
+
//
|
|
5
|
+
// Copyright © 2025 Altcraft. All rights reserved.
|
|
6
|
+
|
|
7
|
+
import androidx.annotation.Keep
|
|
8
|
+
import com.altcraft.sdk.interfaces.RustoreInterface
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* React Native RuStore token provider implementation.
|
|
12
|
+
*
|
|
13
|
+
* This provider acts as a bridge between the JavaScript side and the native SDK.
|
|
14
|
+
* React Native supplies the RuStore token manually, and the SDK retrieves it
|
|
15
|
+
* through this implementation of [RustoreInterface].
|
|
16
|
+
*
|
|
17
|
+
* Notes:
|
|
18
|
+
* - The token is stored in memory only. It is not persisted and will be lost
|
|
19
|
+
* when the process is killed.
|
|
20
|
+
*/
|
|
21
|
+
@Keep
|
|
22
|
+
object RnRuStoreProvider : RustoreInterface {
|
|
23
|
+
|
|
24
|
+
@Volatile
|
|
25
|
+
private var token: String? = null
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the currently stored RuStore token or null.
|
|
29
|
+
*/
|
|
30
|
+
override suspend fun getToken(): String? = token
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Deletes the current RuStore token and invokes the completion callback.
|
|
34
|
+
*/
|
|
35
|
+
override suspend fun deleteToken(complete: (Boolean) -> Unit) {
|
|
36
|
+
token = null
|
|
37
|
+
complete(true)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Sets a new RuStore token.
|
|
42
|
+
*/
|
|
43
|
+
fun setToken(newToken: String?) {
|
|
44
|
+
token = newToken
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Clears the stored RuStore token.
|
|
49
|
+
*/
|
|
50
|
+
fun clear() {
|
|
51
|
+
token = null
|
|
52
|
+
}
|
|
53
|
+
}
|
package/ios/Sdk.h
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#ifdef __OBJC__
|
|
4
|
+
|
|
5
|
+
#import <Foundation/Foundation.h>
|
|
6
|
+
|
|
7
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
8
|
+
#import <Sdk/Sdk.h>
|
|
9
|
+
|
|
10
|
+
NS_EXTENSION_UNAVAILABLE_IOS("Altcraft RN bridge is unavailable in app extensions.")
|
|
11
|
+
@interface Sdk : NSObject <NativeSdkSpec>
|
|
12
|
+
#else
|
|
13
|
+
NS_EXTENSION_UNAVAILABLE_IOS("Altcraft RN bridge is unavailable in app extensions.")
|
|
14
|
+
@interface Sdk : NSObject
|
|
15
|
+
#endif
|
|
16
|
+
|
|
17
|
+
@end
|
|
18
|
+
|
|
19
|
+
#endif // __OBJC__
|