@onekeyfe/react-native-lite-card 0.1.2
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 +37 -0
- package/ReactNativeLiteCard.podspec +22 -0
- package/android/build.gradle +79 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/config/command.json +205 -0
- package/android/src/main/cpp/CMakeLists.txt +19 -0
- package/android/src/main/cpp/validation.c +227 -0
- package/android/src/main/cpp/validation.h +19 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/LoggerManager.kt +35 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardModule.kt +420 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/ReactNativeLiteCardPackage.kt +33 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/keys/KeysNativeProvider.kt +13 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/Exceptions.kt +58 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/NfcUtils.kt +142 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/broadcast/NfcStatusChangeBroadcastReceiver.kt +56 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/nfc/gpchannel/GPChannelNatives.kt +32 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/NfcConstant.kt +38 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/OnekeyLiteCard.kt +236 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/APDUParam.kt +17 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/CardInfo.java +84 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/CardResponse.java +37 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/CardState.kt +10 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/ParsedCertInfo.java +39 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SecureChanelParam.java +113 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/entitys/SendResponse.kt +26 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/CommandGenerator.kt +178 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/Connection.kt +439 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/onekeyLite/nfc/GPCAPDUGenerator.kt +56 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/EventUtils.kt +14 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/GpsUtil.kt +38 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/HexUtils.java +93 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/LogUtil.kt +11 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/MiUtil.kt +93 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/NfcPermissionUtils.kt +24 -0
- package/android/src/main/java/com/onekeyfe/reactnativelitecard/utils/Utils.java +437 -0
- package/android/src/main/jniLibs/arm64-v8a/libgpchannelNDK.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libgpchannelNDK.so +0 -0
- package/ios/Classes/OKLiteCommand/OKLiteCommandModal.h +39 -0
- package/ios/Classes/OKLiteCommand/OKLiteCommandModal.m +143 -0
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.h +28 -0
- package/ios/Classes/OKLiteCommand/OKLiteCommandTool.m +53 -0
- package/ios/Classes/OKNFCBridge.h +28 -0
- package/ios/Classes/OKNFCBridge.mm +221 -0
- package/ios/Classes/OKNFCLiteDefine.h +108 -0
- package/ios/Classes/OKNFTLite/OKLiteProtocol.h +37 -0
- package/ios/Classes/OKNFTLite/OKLiteV1.h +41 -0
- package/ios/Classes/OKNFTLite/OKLiteV1.m +609 -0
- package/ios/Classes/OKNFTLite/OKLiteV2.h +17 -0
- package/ios/Classes/OKNFTLite/OKLiteV2.m +132 -0
- package/ios/Classes/OKNFTLite/OKNFCManager.h +40 -0
- package/ios/Classes/OKNFTLite/OKNFCManager.m +330 -0
- package/ios/Classes/Utils/NFCConfig.h +19 -0
- package/ios/Classes/Utils/NFCConfig.m +18 -0
- package/ios/Classes/Utils/NSData+OKNFCHexData.h +17 -0
- package/ios/Classes/Utils/NSData+OKNFCHexData.m +24 -0
- package/ios/Classes/Utils/NSData+StringToData.h +12 -0
- package/ios/Classes/Utils/NSData+StringToData.m +25 -0
- package/ios/Classes/Utils/NSString+OKAdd.h +14 -0
- package/ios/Classes/Utils/NSString+OKAdd.m +40 -0
- package/ios/Classes/Utils/NSString+OKNFCHexStr.h +18 -0
- package/ios/Classes/Utils/NSString+OKNFCHexStr.m +38 -0
- package/ios/Classes/Utils/OKNFCUtility.h +18 -0
- package/ios/Classes/Utils/OKNFCUtility.m +22 -0
- package/ios/Classes/Utils/OKTools.h +17 -0
- package/ios/Classes/Utils/OKTools.m +21 -0
- package/ios/GPChannelSDKCore.xcframework/Info.plist +52 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +315 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +19 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Info.plist +0 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/Modules/module.modulemap +7 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64/GPChannelSDKCore.framework/_CodeSignature/CodeResources +147 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/GPChannelSDKCore +0 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDK.h +315 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Headers/GPChannelSDKCore.h +19 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Info.plist +0 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/Modules/module.modulemap +7 -0
- package/ios/GPChannelSDKCore.xcframework/ios-arm64_x86_64-simulator/GPChannelSDKCore.framework/_CodeSignature/CodeResources +147 -0
- package/ios/ReactNativeLiteCard.h +5 -0
- package/ios/ReactNativeLiteCard.mm +222 -0
- package/lib/module/NativeReactNativeLiteCard.js +25 -0
- package/lib/module/NativeReactNativeLiteCard.js.map +1 -0
- package/lib/module/index.js +71 -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/NativeReactNativeLiteCard.d.ts +59 -0
- package/lib/typescript/src/NativeReactNativeLiteCard.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +23 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/package.json +168 -0
- package/src/NativeReactNativeLiteCard.ts +112 -0
- package/src/index.tsx +94 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
TurboModuleRegistry,
|
|
3
|
+
type CodegenTypes,
|
|
4
|
+
type TurboModule,
|
|
5
|
+
} from 'react-native';
|
|
6
|
+
|
|
7
|
+
export type CallbackError = { code: number; message: string | null } | null;
|
|
8
|
+
|
|
9
|
+
export type CardInfo = {
|
|
10
|
+
hasBackup: boolean;
|
|
11
|
+
isNewCard: boolean;
|
|
12
|
+
serialNum: string;
|
|
13
|
+
pinRetryCount: number;
|
|
14
|
+
} | null;
|
|
15
|
+
|
|
16
|
+
export type CallbackResult<T> = [
|
|
17
|
+
error: CallbackError | null,
|
|
18
|
+
data: T | null,
|
|
19
|
+
cardInfo: CardInfo | null
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
export type PromiseResult<T> = {
|
|
23
|
+
error: CallbackError | null;
|
|
24
|
+
data: T | null;
|
|
25
|
+
cardInfo: CardInfo | null;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export enum CardErrors {
|
|
29
|
+
InitChannel = 1000,
|
|
30
|
+
NotExistsNFC = 1001,
|
|
31
|
+
NotEnableNFC = 1002,
|
|
32
|
+
NotNFCPermission = 1003,
|
|
33
|
+
|
|
34
|
+
ConnectionFail = 2001,
|
|
35
|
+
InterruptError = 2002,
|
|
36
|
+
DeviceMismatch = 2003,
|
|
37
|
+
UserCancel = 2004,
|
|
38
|
+
|
|
39
|
+
PasswordWrong = 3001,
|
|
40
|
+
InputPasswordEmpty = 3002,
|
|
41
|
+
NotSetPassword = 3003,
|
|
42
|
+
InitPasswordError = 3004,
|
|
43
|
+
CardLock = 3005,
|
|
44
|
+
UpperErrorAutoReset = 3006,
|
|
45
|
+
|
|
46
|
+
ExecFailure = 4000,
|
|
47
|
+
InitializedError = 4001,
|
|
48
|
+
NotInitializedError = 4002,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
type KeyValuePair = {
|
|
52
|
+
code: string;
|
|
53
|
+
message: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export interface Spec extends TurboModule {
|
|
57
|
+
getLiteInfo(
|
|
58
|
+
callback: (
|
|
59
|
+
error: CallbackError | null,
|
|
60
|
+
data: CardInfo | null,
|
|
61
|
+
cardInfo: CardInfo | null
|
|
62
|
+
) => void
|
|
63
|
+
): void;
|
|
64
|
+
checkNFCPermission(
|
|
65
|
+
callback: (
|
|
66
|
+
error: CallbackError | null,
|
|
67
|
+
data: boolean | null,
|
|
68
|
+
cardInfo: CardInfo | null
|
|
69
|
+
) => void
|
|
70
|
+
): void;
|
|
71
|
+
setMnemonic(
|
|
72
|
+
mnemonic: string,
|
|
73
|
+
pwd: string,
|
|
74
|
+
overwrite: boolean,
|
|
75
|
+
callback: (
|
|
76
|
+
error: CallbackError | null,
|
|
77
|
+
data: boolean | null,
|
|
78
|
+
cardInfo: CardInfo | null
|
|
79
|
+
) => void
|
|
80
|
+
): void;
|
|
81
|
+
getMnemonicWithPin(
|
|
82
|
+
pwd: string,
|
|
83
|
+
callback: (
|
|
84
|
+
error: CallbackError | null,
|
|
85
|
+
data: string | null,
|
|
86
|
+
cardInfo: CardInfo | null
|
|
87
|
+
) => void
|
|
88
|
+
): void;
|
|
89
|
+
changePin(
|
|
90
|
+
oldPin: string,
|
|
91
|
+
newPin: string,
|
|
92
|
+
callback: (
|
|
93
|
+
error: CallbackError | null,
|
|
94
|
+
data: boolean | null,
|
|
95
|
+
cardInfo: CardInfo | null
|
|
96
|
+
) => void
|
|
97
|
+
): void;
|
|
98
|
+
reset(
|
|
99
|
+
callback: (
|
|
100
|
+
error: CallbackError | null,
|
|
101
|
+
data: boolean | null,
|
|
102
|
+
cardInfo: CardInfo | null
|
|
103
|
+
) => void
|
|
104
|
+
): void;
|
|
105
|
+
cancel(): void;
|
|
106
|
+
intoSetting(): void;
|
|
107
|
+
|
|
108
|
+
readonly onNFCActiveConnection: CodegenTypes.EventEmitter<KeyValuePair>;
|
|
109
|
+
readonly onNFCUIEvent: CodegenTypes.EventEmitter<KeyValuePair>;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('ReactNativeLiteCard');
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { Linking, Platform } from 'react-native';
|
|
2
|
+
import OKLiteManager from './NativeReactNativeLiteCard';
|
|
3
|
+
import type {
|
|
4
|
+
CallbackResult,
|
|
5
|
+
CardInfo,
|
|
6
|
+
PromiseResult,
|
|
7
|
+
} from './NativeReactNativeLiteCard';
|
|
8
|
+
|
|
9
|
+
export type NfcConnectUiState = {
|
|
10
|
+
code: number;
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
class OnekeyLite {
|
|
14
|
+
addConnectListener(listener: (event: NfcConnectUiState) => void) {
|
|
15
|
+
this.removeConnectListeners();
|
|
16
|
+
return OKLiteManager.onNFCUIEvent((event) => {
|
|
17
|
+
listener({
|
|
18
|
+
code: Number(event.code),
|
|
19
|
+
message: event.message,
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
removeConnectListeners() {}
|
|
25
|
+
|
|
26
|
+
addAccordListener() {
|
|
27
|
+
return OKLiteManager.onNFCActiveConnection(() => {});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getLiteInfo() {
|
|
31
|
+
return new Promise<PromiseResult<CardInfo>>((resolve) => {
|
|
32
|
+
OKLiteManager.getLiteInfo(this.convertToPromise(resolve));
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
checkNFCPermission() {
|
|
37
|
+
return new Promise<PromiseResult<boolean>>((resolve) => {
|
|
38
|
+
OKLiteManager.checkNFCPermission(this.convertToPromise(resolve));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
setMnemonic(mnemonic: string, pwd: string, overwrite = false) {
|
|
43
|
+
return new Promise<PromiseResult<boolean>>((resolve) => {
|
|
44
|
+
OKLiteManager.setMnemonic(
|
|
45
|
+
mnemonic,
|
|
46
|
+
pwd,
|
|
47
|
+
overwrite,
|
|
48
|
+
this.convertToPromise(resolve)
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
getMnemonicWithPin(pwd: string) {
|
|
54
|
+
return new Promise<PromiseResult<string>>((resolve) => {
|
|
55
|
+
OKLiteManager.getMnemonicWithPin(pwd, this.convertToPromise(resolve));
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
changePin(oldPin: string, newPin: string) {
|
|
60
|
+
return new Promise<PromiseResult<boolean>>((resolve) => {
|
|
61
|
+
OKLiteManager.changePin(oldPin, newPin, this.convertToPromise(resolve));
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
reset() {
|
|
66
|
+
return new Promise<PromiseResult<boolean>>((resolve) => {
|
|
67
|
+
OKLiteManager.reset(this.convertToPromise(resolve));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
convertToPromise<T>(
|
|
72
|
+
resolve: (value: PromiseResult<T> | PromiseLike<PromiseResult<T>>) => void
|
|
73
|
+
) {
|
|
74
|
+
return (...result: CallbackResult<T>) => {
|
|
75
|
+
resolve({ error: result[0], data: result[1], cardInfo: result[2] });
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
cancel() {
|
|
80
|
+
if (Platform.OS === 'android') OKLiteManager.cancel();
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
intoSetting() {
|
|
84
|
+
if (Platform.OS === 'android') {
|
|
85
|
+
OKLiteManager.intoSetting();
|
|
86
|
+
} else {
|
|
87
|
+
Linking.openSettings();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const onekeyLite = new OnekeyLite();
|
|
93
|
+
export default onekeyLite;
|
|
94
|
+
export type * from './NativeReactNativeLiteCard';
|