@digitalshieldfe/react-native-backup-card-sdk 0.1.4 → 0.1.6
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/android/build.gradle +33 -49
- package/android/libs/backupcardsdk.aar +0 -0
- package/android/src/main/AndroidManifest.xml +1 -4
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/BackupCardSdkModule.kt +244 -74
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/BackupCardSdkPackage.kt +1 -1
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/nfc/NfcExceptions.kt +11 -0
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/nfc/NfcUtils.kt +30 -0
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/utils/MiUtil.kt +74 -0
- package/android/src/main/java/com/ziancube/reactnativebackupcardsdk/utils/NfcPermissionUtils.kt +23 -0
- package/lib/module/NativeBackupCardSdk.js +3 -0
- package/lib/module/NativeBackupCardSdk.js.map +1 -1
- package/lib/module/cardOperations.js +27 -0
- package/lib/module/cardOperations.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/nfc.js +75 -0
- package/lib/module/nfc.js.map +1 -0
- package/lib/typescript/src/NativeBackupCardSdk.d.ts +50 -4
- package/lib/typescript/src/NativeBackupCardSdk.d.ts.map +1 -1
- package/lib/typescript/src/cardOperations.d.ts +7 -0
- package/lib/typescript/src/cardOperations.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +5 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/nfc.d.ts +28 -0
- package/lib/typescript/src/nfc.d.ts.map +1 -0
- package/package.json +7 -5
- package/src/NativeBackupCardSdk.ts +62 -4
- package/src/cardOperations.ts +61 -0
- package/src/index.tsx +22 -2
- package/src/nfc.ts +74 -0
- package/android/consumer-rules.pro +0 -0
- package/android/proguard-rules.pro +0 -21
- package/android/src/main/java/com/ziancube/backupcardsdk/BackupCardSdk.kt +0 -478
- package/android/src/main/java/com/ziancube/backupcardsdk/GPChannelNatives.java +0 -41
- package/android/src/main/java/com/ziancube/backupcardsdk/listener/ApiAsyncListener.java +0 -13
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ApiNfc.java +0 -173
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/ImplNfc.java +0 -39
- package/android/src/main/java/com/ziancube/backupcardsdk/nfc/NfcComm.java +0 -115
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/ApduParam.java +0 -67
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/CommList.java +0 -41
- package/android/src/main/java/com/ziancube/backupcardsdk/utils/Utils.java +0 -109
- package/android/src/main/jni/CMakeLists.txt +0 -60
- package/android/src/main/jni/GPChannel/include/GPChannelSDK.h +0 -306
- package/android/src/main/jni/GPChannel/include/context/BaseContext.h +0 -56
- package/android/src/main/jni/GPChannel/include/device/ApduBuilder.hpp +0 -72
- package/android/src/main/jni/GPChannel/include/utility/Apdu.hpp +0 -166
- package/android/src/main/jni/GPChannel/include/utility/Debug.hpp +0 -59
- package/android/src/main/jni/GPChannel/include/utility/Singleton.h +0 -34
- package/android/src/main/jni/GPChannel/include/utility/mutex.h +0 -24
- package/android/src/main/jni/GPChannel/include/utility/trim.hpp +0 -155
- package/android/src/main/jni/GPChannel/include/utility/util.h +0 -104
- package/android/src/main/jni/GPChannel/include/utility/xFactory.hpp +0 -26
- package/android/src/main/jni/GPChannel/include/utility/xManager.hpp +0 -84
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/arm64-v8a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/armeabi-v7a/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libJUB_GPC_APDU_SDK.a +0 -0
- package/android/src/main/jni/GPChannel/src/x86/libTrezorCrypto.a +0 -0
- package/android/src/main/jni/src/implJni.cpp +0 -313
- package/android/src/main/jni/src/implJni.h +0 -9
- package/android/src/main/jni/utils/jsoncpp/AUTHORS +0 -111
- package/android/src/main/jni/utils/jsoncpp/CMakeLists.txt +0 -159
- package/android/src/main/jni/utils/jsoncpp/LICENSE +0 -55
- package/android/src/main/jni/utils/jsoncpp/README.md +0 -135
- package/android/src/main/jni/utils/jsoncpp/amalgamate.py +0 -155
- package/android/src/main/jni/utils/jsoncpp/appveyor.yml +0 -22
- package/android/src/main/jni/utils/jsoncpp/dev.makefile +0 -35
- package/android/src/main/jni/utils/jsoncpp/devtools/__init__.py +0 -6
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmw7.json +0 -33
- package/android/src/main/jni/utils/jsoncpp/devtools/agent_vmxp.json +0 -26
- package/android/src/main/jni/utils/jsoncpp/devtools/antglob.py +0 -205
- package/android/src/main/jni/utils/jsoncpp/devtools/batchbuild.py +0 -278
- package/android/src/main/jni/utils/jsoncpp/devtools/fixeol.py +0 -70
- package/android/src/main/jni/utils/jsoncpp/devtools/licenseupdater.py +0 -94
- package/android/src/main/jni/utils/jsoncpp/devtools/tarball.py +0 -52
- package/android/src/main/jni/utils/jsoncpp/doxybuild.py +0 -189
- package/android/src/main/jni/utils/jsoncpp/include/CMakeLists.txt +0 -2
- package/android/src/main/jni/utils/jsoncpp/include/json/allocator.h +0 -98
- package/android/src/main/jni/utils/jsoncpp/include/json/assertions.h +0 -54
- package/android/src/main/jni/utils/jsoncpp/include/json/autolink.h +0 -25
- package/android/src/main/jni/utils/jsoncpp/include/json/config.h +0 -187
- package/android/src/main/jni/utils/jsoncpp/include/json/features.h +0 -61
- package/android/src/main/jni/utils/jsoncpp/include/json/forwards.h +0 -37
- package/android/src/main/jni/utils/jsoncpp/include/json/json.h +0 -15
- package/android/src/main/jni/utils/jsoncpp/include/json/reader.h +0 -411
- package/android/src/main/jni/utils/jsoncpp/include/json/value.h +0 -888
- package/android/src/main/jni/utils/jsoncpp/include/json/version.h +0 -20
- package/android/src/main/jni/utils/jsoncpp/include/json/writer.h +0 -357
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/jsontest.vcproj +0 -119
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/lib_json.vcproj +0 -205
- package/android/src/main/jni/utils/jsoncpp/makefiles/vs71/test_lib_json.vcproj +0 -130
- package/android/src/main/jni/utils/jsoncpp/makerelease.py +0 -390
- package/android/src/main/jni/utils/jsoncpp/meson.build +0 -103
- package/android/src/main/jni/utils/jsoncpp/pkg-config/jsoncpp.pc.in +0 -9
- package/android/src/main/jni/utils/jsoncpp/src/CMakeLists.txt +0 -5
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/CMakeLists.txt +0 -25
- package/android/src/main/jni/utils/jsoncpp/src/jsontestrunner/main.cpp +0 -333
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/CMakeLists.txt +0 -117
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_reader.cpp +0 -2060
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_tool.h +0 -114
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_value.cpp +0 -1661
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_valueiterator.inl +0 -167
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/json_writer.cpp +0 -1233
- package/android/src/main/jni/utils/jsoncpp/src/lib_json/version.h.in +0 -20
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/CMakeLists.txt +0 -38
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.cpp +0 -457
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/jsontest.h +0 -286
- package/android/src/main/jni/utils/jsoncpp/src/test_lib_json/main.cpp +0 -2606
- package/android/src/main/jni/utils/jsoncpp/travis.sh +0 -23
- package/android/src/main/jni/utils/jsoncpp/version +0 -1
- package/android/src/main/jni/utils/jsoncpp/version.in +0 -1
- package/android/src/main/jni/utils/logUtils.cpp +0 -108
- package/android/src/main/jni/utils/logUtils.h +0 -87
- package/android/src/main/jni/utils/mSIGNA/stdutils/uchar_vector.h +0 -614
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import { TurboModuleRegistry } from 'react-native';
|
|
4
|
+
|
|
5
|
+
/** App-layer result type (same pattern as react-native-lite-card PromiseResult). */
|
|
6
|
+
|
|
4
7
|
export default TurboModuleRegistry.getEnforcing('BackupCardSdk');
|
|
5
8
|
//# sourceMappingURL=NativeBackupCardSdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBackupCardSdk.ts"],"mappings":";;AAAA,SACEA,mBAAmB,QAGd,cAAc
|
|
1
|
+
{"version":3,"names":["TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeBackupCardSdk.ts"],"mappings":";;AAAA,SACEA,mBAAmB,QAGd,cAAc;;AAWrB;;AA+EA,eAAeA,mBAAmB,CAACC,YAAY,CAAO,eAAe,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import BackupCardSdk from "./NativeBackupCardSdk.js";
|
|
4
|
+
function withoutData(result) {
|
|
5
|
+
return {
|
|
6
|
+
error: result.error,
|
|
7
|
+
cardInfo: result.cardInfo,
|
|
8
|
+
resultCode: result.resultCode,
|
|
9
|
+
data: null
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export async function activateCard(pwd, serialNumber) {
|
|
13
|
+
return withoutData(await BackupCardSdk.activateCard(pwd, serialNumber));
|
|
14
|
+
}
|
|
15
|
+
export async function checkSlotEmpty(slotId, pwd) {
|
|
16
|
+
return withoutData(await BackupCardSdk.checkSlotEmpty(slotId, pwd));
|
|
17
|
+
}
|
|
18
|
+
export async function writeSlot(slotIndex, data, pwd) {
|
|
19
|
+
return withoutData(await BackupCardSdk.writeSlot(slotIndex, data, pwd));
|
|
20
|
+
}
|
|
21
|
+
export async function readSlot(slotIndex, pwd) {
|
|
22
|
+
return BackupCardSdk.readSlot(slotIndex, pwd);
|
|
23
|
+
}
|
|
24
|
+
export async function deleteSlot(slotIndex, pwd) {
|
|
25
|
+
return withoutData(await BackupCardSdk.deleteSlot(slotIndex, pwd));
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=cardOperations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["BackupCardSdk","withoutData","result","error","cardInfo","resultCode","data","activateCard","pwd","serialNumber","checkSlotEmpty","slotId","writeSlot","slotIndex","readSlot","deleteSlot"],"sourceRoot":"../../src","sources":["cardOperations.ts"],"mappings":";;AAAA,OAAOA,aAAa,MAAM,0BAAuB;AAejD,SAASC,WAAWA,CAClBC,MAAiC,EACN;EAC3B,OAAO;IACLC,KAAK,EAAED,MAAM,CAACC,KAAK;IACnBC,QAAQ,EAAEF,MAAM,CAACE,QAAQ;IACzBC,UAAU,EAAEH,MAAM,CAACG,UAAU;IAC7BC,IAAI,EAAE;EACR,CAAC;AACH;AAEA,OAAO,eAAeC,YAAYA,CAChCC,GAAW,EACXC,YAAoB,EACgB;EACpC,OAAOR,WAAW,CAAC,MAAMD,aAAa,CAACO,YAAY,CAACC,GAAG,EAAEC,YAAY,CAAC,CAAC;AACzE;AAEA,OAAO,eAAeC,cAAcA,CAClCC,MAAc,EACdH,GAAW,EACyB;EACpC,OAAOP,WAAW,CAAC,MAAMD,aAAa,CAACU,cAAc,CAACC,MAAM,EAAEH,GAAG,CAAC,CAAC;AACrE;AAEA,OAAO,eAAeI,SAASA,CAC7BC,SAAiB,EACjBP,IAAmB,EACnBE,GAAW,EACyB;EACpC,OAAOP,WAAW,CAAC,MAAMD,aAAa,CAACY,SAAS,CAACC,SAAS,EAAEP,IAAI,EAAEE,GAAG,CAAC,CAAC;AACzE;AAEA,OAAO,eAAeM,QAAQA,CAC5BD,SAAiB,EACjBL,GAAW,EAC2B;EACtC,OAAOR,aAAa,CAACc,QAAQ,CAACD,SAAS,EAAEL,GAAG,CAAC;AAC/C;AAEA,OAAO,eAAeO,UAAUA,CAC9BF,SAAiB,EACjBL,GAAW,EACyB;EACpC,OAAOP,WAAW,CAAC,MAAMD,aAAa,CAACe,UAAU,CAACF,SAAS,EAAEL,GAAG,CAAC,CAAC;AACpE","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
import BackupCardSdk from "./NativeBackupCardSdk.js";
|
|
4
|
+
export { CardErrors, cancelNfcWait, checkNFCPermission, intoSetting } from "./nfc.js";
|
|
5
|
+
export { activateCard, checkSlotEmpty, deleteSlot, readSlot, writeSlot } from "./cardOperations.js";
|
|
4
6
|
export default BackupCardSdk;
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BackupCardSdk"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,aAAa,MAAM,0BAAuB;
|
|
1
|
+
{"version":3,"names":["BackupCardSdk","CardErrors","cancelNfcWait","checkNFCPermission","intoSetting","activateCard","checkSlotEmpty","deleteSlot","readSlot","writeSlot"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,OAAOA,aAAa,MAAM,0BAAuB;AASjD,SACEC,UAAU,EACVC,aAAa,EACbC,kBAAkB,EAClBC,WAAW,QACN,UAAO;AACd,SACEC,YAAY,EACZC,cAAc,EACdC,UAAU,EACVC,QAAQ,EACRC,SAAS,QACJ,qBAAkB;AAEzB,eAAeT,aAAa","ignoreList":[]}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { Platform } from 'react-native';
|
|
4
|
+
import BackupCardSdk from "./NativeBackupCardSdk.js";
|
|
5
|
+
/** Same error codes as @digitalshieldfe/react-native-lite-card for NFC checks. */
|
|
6
|
+
export let CardErrors = /*#__PURE__*/function (CardErrors) {
|
|
7
|
+
CardErrors[CardErrors["InitChannel"] = 1000] = "InitChannel";
|
|
8
|
+
CardErrors[CardErrors["NotExistsNFC"] = 1001] = "NotExistsNFC";
|
|
9
|
+
CardErrors[CardErrors["NotEnableNFC"] = 1002] = "NotEnableNFC";
|
|
10
|
+
CardErrors[CardErrors["NotNFCPermission"] = 1003] = "NotNFCPermission";
|
|
11
|
+
CardErrors[CardErrors["ConnectionFail"] = 2001] = "ConnectionFail";
|
|
12
|
+
CardErrors[CardErrors["NotSameNFCLite"] = 2002] = "NotSameNFCLite";
|
|
13
|
+
CardErrors[CardErrors["ActivateCardFailed"] = 2003] = "ActivateCardFailed";
|
|
14
|
+
CardErrors[CardErrors["NotSupportedCard"] = 2004] = "NotSupportedCard";
|
|
15
|
+
CardErrors[CardErrors["PasswordWrong"] = 2005] = "PasswordWrong";
|
|
16
|
+
CardErrors[CardErrors["NotSetPassword"] = 2006] = "NotSetPassword";
|
|
17
|
+
CardErrors[CardErrors["CardLock"] = 2007] = "CardLock";
|
|
18
|
+
CardErrors[CardErrors["NotInitializedError"] = 2008] = "NotInitializedError";
|
|
19
|
+
CardErrors[CardErrors["InitializedError"] = 4001] = "InitializedError";
|
|
20
|
+
return CardErrors;
|
|
21
|
+
}({});
|
|
22
|
+
function parseTurboModuleError(error) {
|
|
23
|
+
const err = error;
|
|
24
|
+
const code = err?.userInfo?.code;
|
|
25
|
+
if (typeof code === 'number') {
|
|
26
|
+
return {
|
|
27
|
+
code,
|
|
28
|
+
message: err.userInfo?.message ?? err.message ?? null
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
return {
|
|
32
|
+
code: CardErrors.InitChannel,
|
|
33
|
+
message: err?.message ?? null
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Android only for now; iOS will be added later. */
|
|
38
|
+
export function checkNFCPermission() {
|
|
39
|
+
if (Platform.OS !== 'android') {
|
|
40
|
+
return Promise.resolve({
|
|
41
|
+
error: {
|
|
42
|
+
code: CardErrors.InitChannel,
|
|
43
|
+
message: 'checkNFCPermission is not implemented on iOS yet'
|
|
44
|
+
},
|
|
45
|
+
data: null,
|
|
46
|
+
cardInfo: null,
|
|
47
|
+
resultCode: -1
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return BackupCardSdk.checkNFCPermission().then(() => ({
|
|
51
|
+
error: null,
|
|
52
|
+
data: true,
|
|
53
|
+
cardInfo: null,
|
|
54
|
+
resultCode: 0
|
|
55
|
+
})).catch(error => ({
|
|
56
|
+
error: parseTurboModuleError(error),
|
|
57
|
+
data: null,
|
|
58
|
+
cardInfo: null,
|
|
59
|
+
resultCode: -1
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Android only for now; iOS will be added later. */
|
|
64
|
+
export function intoSetting() {
|
|
65
|
+
if (Platform.OS !== 'android') {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
BackupCardSdk.intoSetting();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Call when user dismisses the "tap card" UI to stop waiting. Android only. */
|
|
72
|
+
export function cancelNfcWait() {
|
|
73
|
+
BackupCardSdk.cancelNfcWait();
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=nfc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["Platform","BackupCardSdk","CardErrors","parseTurboModuleError","error","err","code","userInfo","message","InitChannel","checkNFCPermission","OS","Promise","resolve","data","cardInfo","resultCode","then","catch","intoSetting","cancelNfcWait"],"sourceRoot":"../../src","sources":["nfc.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAOC,aAAa,MAAM,0BAAuB;AAMjD;AACA,WAAYC,UAAU,0BAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAVA,UAAU,CAAVA,UAAU;EAAA,OAAVA,UAAU;AAAA;AAkBtB,SAASC,qBAAqBA,CAACC,KAAc,EAAiB;EAC5D,MAAMC,GAAG,GAAGD,KAGX;EACD,MAAME,IAAI,GAAGD,GAAG,EAAEE,QAAQ,EAAED,IAAI;EAChC,IAAI,OAAOA,IAAI,KAAK,QAAQ,EAAE;IAC5B,OAAO;MAAEA,IAAI;MAAEE,OAAO,EAAEH,GAAG,CAACE,QAAQ,EAAEC,OAAO,IAAIH,GAAG,CAACG,OAAO,IAAI;IAAK,CAAC;EACxE;EACA,OAAO;IAAEF,IAAI,EAAEJ,UAAU,CAACO,WAAW;IAAED,OAAO,EAAEH,GAAG,EAAEG,OAAO,IAAI;EAAK,CAAC;AACxE;;AAEA;AACA,OAAO,SAASE,kBAAkBA,CAAA,EAAoC;EACpE,IAAIV,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAOC,OAAO,CAACC,OAAO,CAAC;MACrBT,KAAK,EAAE;QACLE,IAAI,EAAEJ,UAAU,CAACO,WAAW;QAC5BD,OAAO,EAAE;MACX,CAAC;MACDM,IAAI,EAAE,IAAI;MACVC,QAAQ,EAAE,IAAI;MACdC,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;EACJ;EACA,OAAOf,aAAa,CAACS,kBAAkB,CAAC,CAAC,CACtCO,IAAI,CAAC,OAAO;IAAEb,KAAK,EAAE,IAAI;IAAEU,IAAI,EAAE,IAAI;IAAEC,QAAQ,EAAE,IAAI;IAAEC,UAAU,EAAE;EAAE,CAAC,CAAC,CAAC,CACxEE,KAAK,CAAEd,KAAc,KAAM;IAC1BA,KAAK,EAAED,qBAAqB,CAACC,KAAK,CAAC;IACnCU,IAAI,EAAE,IAAI;IACVC,QAAQ,EAAE,IAAI;IACdC,UAAU,EAAE,CAAC;EACf,CAAC,CAAC,CAAC;AACP;;AAEA;AACA,OAAO,SAASG,WAAWA,CAAA,EAAS;EAClC,IAAInB,QAAQ,CAACW,EAAE,KAAK,SAAS,EAAE;IAC7B;EACF;EACAV,aAAa,CAACkB,WAAW,CAAC,CAAC;AAC7B;;AAEA;AACA,OAAO,SAASC,aAAaA,CAAA,EAAS;EACpCnB,aAAa,CAACmB,aAAa,CAAC,CAAC;AAC/B","ignoreList":[]}
|
|
@@ -3,15 +3,61 @@ export type CardInfo = {
|
|
|
3
3
|
serialNumber: string | null;
|
|
4
4
|
pinRetryCount: number | null;
|
|
5
5
|
isNewCard: boolean | null;
|
|
6
|
+
isBackup: boolean | null;
|
|
6
7
|
};
|
|
8
|
+
export type CallbackError = {
|
|
9
|
+
code: number;
|
|
10
|
+
message: string | null;
|
|
11
|
+
};
|
|
12
|
+
/** App-layer result type (same pattern as react-native-lite-card PromiseResult). */
|
|
13
|
+
export type PromiseResult<T> = {
|
|
14
|
+
error: CallbackError | null;
|
|
15
|
+
data: T | null;
|
|
16
|
+
cardInfo: CardInfo | null;
|
|
17
|
+
resultCode: number;
|
|
18
|
+
};
|
|
19
|
+
export type CardOperationResult<T> = PromiseResult<T>;
|
|
7
20
|
export interface Spec extends TurboModule {
|
|
21
|
+
/** Waits for user to tap the backup card (Android), then reads card info. */
|
|
8
22
|
getCardInfo(): Promise<CardInfo | null>;
|
|
23
|
+
/** Cancels an in-flight wait for NFC tap (Android). */
|
|
24
|
+
cancelNfcWait(): void;
|
|
25
|
+
/** Android: hardware NFC, system switch, MIUI permission. iOS: not implemented yet. */
|
|
26
|
+
checkNFCPermission(): Promise<boolean>;
|
|
27
|
+
/** Android: opens system NFC settings. iOS: not implemented yet. */
|
|
28
|
+
intoSetting(): void;
|
|
9
29
|
resetCard(): Promise<Boolean>;
|
|
10
|
-
activateCard(pwd: string): Promise<
|
|
30
|
+
activateCard(pwd: string, serialNumber: string): Promise<{
|
|
31
|
+
error: CallbackError | null;
|
|
32
|
+
cardInfo: CardInfo | null;
|
|
33
|
+
resultCode: number;
|
|
34
|
+
data: string | null;
|
|
35
|
+
}>;
|
|
11
36
|
changePin(oldPin: string, newPin: string): Promise<Boolean>;
|
|
12
|
-
checkSlotEmpty(slotId: number, pwd: string): Promise<
|
|
13
|
-
|
|
14
|
-
|
|
37
|
+
checkSlotEmpty(slotId: number, pwd: string): Promise<{
|
|
38
|
+
error: CallbackError | null;
|
|
39
|
+
cardInfo: CardInfo | null;
|
|
40
|
+
resultCode: number;
|
|
41
|
+
data: string | null;
|
|
42
|
+
}>;
|
|
43
|
+
writeSlot(slotIndex: number, data: Array<number>, pwd: string): Promise<{
|
|
44
|
+
error: CallbackError | null;
|
|
45
|
+
cardInfo: CardInfo | null;
|
|
46
|
+
resultCode: number;
|
|
47
|
+
data: string | null;
|
|
48
|
+
}>;
|
|
49
|
+
readSlot(slotIndex: number, pwd: string): Promise<{
|
|
50
|
+
error: CallbackError | null;
|
|
51
|
+
cardInfo: CardInfo | null;
|
|
52
|
+
resultCode: number;
|
|
53
|
+
data: string | null;
|
|
54
|
+
}>;
|
|
55
|
+
deleteSlot(slotIndex: number, pwd: string): Promise<{
|
|
56
|
+
error: CallbackError | null;
|
|
57
|
+
cardInfo: CardInfo | null;
|
|
58
|
+
resultCode: number;
|
|
59
|
+
data: string | null;
|
|
60
|
+
}>;
|
|
15
61
|
readonly onApduLog: CodegenTypes.EventEmitter<{
|
|
16
62
|
message: string;
|
|
17
63
|
isSent: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeBackupCardSdk.d.ts","sourceRoot":"","sources":["../../../src/NativeBackupCardSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"NativeBackupCardSdk.d.ts","sourceRoot":"","sources":["../../../src/NativeBackupCardSdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,YAAY,EAClB,MAAM,cAAc,CAAC;AAEtB,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAErE,oFAAoF;AACpF,MAAM,MAAM,aAAa,CAAC,CAAC,IAAI;IAC7B,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,CAAC,GAAG,IAAI,CAAC;IACf,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;AAEtD,MAAM,WAAW,IAAK,SAAQ,WAAW;IACvC,6EAA6E;IAC7E,WAAW,IAAI,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACxC,uDAAuD;IACvD,aAAa,IAAI,IAAI,CAAC;IACtB,uFAAuF;IACvF,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,oEAAoE;IACpE,WAAW,IAAI,IAAI,CAAC;IACpB,SAAS,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC9B,YAAY,CACV,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;QACT,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC,CAAC;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC5D,cAAc,CACZ,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QACT,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC,CAAC;IACH,SAAS,CACP,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QACT,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC,CAAC;IACH,QAAQ,CACN,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QACT,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC,CAAC;IACH,UAAU,CACR,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC;QACT,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;QAC1B,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;KACrB,CAAC,CAAC;IAEH,QAAQ,CAAC,SAAS,EAAE,YAAY,CAAC,YAAY,CAAC;QAC5C,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;KACpB,CAAC,CAAC;IAEH,QAAQ,CAAC,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC;QAC7C,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC,CAAC;CACJ;;AAED,wBAAuE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CardOperationResult } from './NativeBackupCardSdk';
|
|
2
|
+
export declare function activateCard(pwd: string, serialNumber: string): Promise<CardOperationResult<null>>;
|
|
3
|
+
export declare function checkSlotEmpty(slotId: number, pwd: string): Promise<CardOperationResult<null>>;
|
|
4
|
+
export declare function writeSlot(slotIndex: number, data: Array<number>, pwd: string): Promise<CardOperationResult<null>>;
|
|
5
|
+
export declare function readSlot(slotIndex: number, pwd: string): Promise<CardOperationResult<string>>;
|
|
6
|
+
export declare function deleteSlot(slotIndex: number, pwd: string): Promise<CardOperationResult<null>>;
|
|
7
|
+
//# sourceMappingURL=cardOperations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cardOperations.d.ts","sourceRoot":"","sources":["../../../src/cardOperations.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAGV,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAoB/B,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAEpC;AAED,wBAAsB,cAAc,CAClC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAEpC;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,MAAM,EACjB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,EACnB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAEpC;AAED,wBAAsB,QAAQ,CAC5B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAEtC;AAED,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC,CAEpC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import BackupCardSdk from './NativeBackupCardSdk';
|
|
2
|
-
import type { CardInfo } from './NativeBackupCardSdk';
|
|
3
|
-
export type { CardInfo };
|
|
2
|
+
import type { CardInfo, CardOperationResult, PromiseResult } from './NativeBackupCardSdk';
|
|
3
|
+
export type { CardInfo, CardOperationResult, PromiseResult };
|
|
4
|
+
export type { CallbackError } from './nfc';
|
|
5
|
+
export { CardErrors, cancelNfcWait, checkNFCPermission, intoSetting, } from './nfc';
|
|
6
|
+
export { activateCard, checkSlotEmpty, deleteSlot, readSlot, writeSlot, } from './cardOperations';
|
|
4
7
|
export default BackupCardSdk;
|
|
5
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EACV,QAAQ,EACR,mBAAmB,EACnB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,QAAQ,EAAE,mBAAmB,EAAE,aAAa,EAAE,CAAC;AAC7D,YAAY,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EACL,UAAU,EACV,aAAa,EACb,kBAAkB,EAClB,WAAW,GACZ,MAAM,OAAO,CAAC;AACf,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,QAAQ,EACR,SAAS,GACV,MAAM,kBAAkB,CAAC;AAE1B,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PromiseResult } from './NativeBackupCardSdk';
|
|
2
|
+
export type CallbackError = {
|
|
3
|
+
code: number;
|
|
4
|
+
message: string | null;
|
|
5
|
+
} | null;
|
|
6
|
+
/** Same error codes as @digitalshieldfe/react-native-lite-card for NFC checks. */
|
|
7
|
+
export declare enum CardErrors {
|
|
8
|
+
InitChannel = 1000,
|
|
9
|
+
NotExistsNFC = 1001,
|
|
10
|
+
NotEnableNFC = 1002,
|
|
11
|
+
NotNFCPermission = 1003,
|
|
12
|
+
ConnectionFail = 2001,
|
|
13
|
+
NotSameNFCLite = 2002,
|
|
14
|
+
ActivateCardFailed = 2003,
|
|
15
|
+
NotSupportedCard = 2004,
|
|
16
|
+
PasswordWrong = 2005,
|
|
17
|
+
NotSetPassword = 2006,
|
|
18
|
+
CardLock = 2007,
|
|
19
|
+
NotInitializedError = 2008,
|
|
20
|
+
InitializedError = 4001
|
|
21
|
+
}
|
|
22
|
+
/** Android only for now; iOS will be added later. */
|
|
23
|
+
export declare function checkNFCPermission(): Promise<PromiseResult<boolean>>;
|
|
24
|
+
/** Android only for now; iOS will be added later. */
|
|
25
|
+
export declare function intoSetting(): void;
|
|
26
|
+
/** Call when user dismisses the "tap card" UI to stop waiting. Android only. */
|
|
27
|
+
export declare function cancelNfcWait(): void;
|
|
28
|
+
//# sourceMappingURL=nfc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nfc.d.ts","sourceRoot":"","sources":["../../../src/nfc.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,IAAI,CAAC;AAE5E,kFAAkF;AAClF,oBAAY,UAAU;IACpB,WAAW,OAAO;IAClB,YAAY,OAAO;IACnB,YAAY,OAAO;IACnB,gBAAgB,OAAO;IAEvB,cAAc,OAAO;IACrB,cAAc,OAAO;IACrB,kBAAkB,OAAO;IACzB,gBAAgB,OAAO;IACvB,aAAa,OAAO;IACpB,cAAc,OAAO;IACrB,QAAQ,OAAO;IACf,mBAAmB,OAAO;IAE1B,gBAAgB,OAAO;CACxB;AAcD,qDAAqD;AACrD,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAoBpE;AAED,qDAAqD;AACrD,wBAAgB,WAAW,IAAI,IAAI,CAKlC;AAED,gFAAgF;AAChF,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digitalshieldfe/react-native-backup-card-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "ds react-native backup-card sdk",
|
|
5
5
|
"main": "./lib/module/index.js",
|
|
6
6
|
"types": "./lib/typescript/src/index.d.ts",
|
|
7
7
|
"exports": {
|
|
8
8
|
".": {
|
|
9
|
-
"source": "./src/index.tsx",
|
|
10
9
|
"types": "./lib/typescript/src/index.d.ts",
|
|
10
|
+
"react-native": "./src/index.tsx",
|
|
11
11
|
"default": "./lib/module/index.js"
|
|
12
12
|
},
|
|
13
13
|
"./package.json": "./package.json"
|
|
@@ -33,7 +33,9 @@
|
|
|
33
33
|
],
|
|
34
34
|
"scripts": {
|
|
35
35
|
"example": "yarn workspace react-native-backup-card-sdk-example",
|
|
36
|
-
"clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
|
|
36
|
+
"clean": "del-cli android/build android/libs/*.aar example/android/build example/android/app/build example/ios/build lib",
|
|
37
|
+
"build:android-aar": "bash scripts/build-android-aar.sh",
|
|
38
|
+
"prepack": "npm run build:android-aar && bob build",
|
|
37
39
|
"prepare": "bob build",
|
|
38
40
|
"typecheck": "tsc",
|
|
39
41
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
@@ -58,7 +60,8 @@
|
|
|
58
60
|
},
|
|
59
61
|
"homepage": "https://www.ds.com#readme",
|
|
60
62
|
"publishConfig": {
|
|
61
|
-
"registry": "https://registry.npmjs.org/"
|
|
63
|
+
"registry": "https://registry.npmjs.org/",
|
|
64
|
+
"access": "public"
|
|
62
65
|
},
|
|
63
66
|
"devDependencies": {
|
|
64
67
|
"@commitlint/config-conventional": "^20.5.0",
|
|
@@ -70,7 +73,6 @@
|
|
|
70
73
|
"@react-native/eslint-config": "0.85.1",
|
|
71
74
|
"@react-native/jest-preset": "0.85.1",
|
|
72
75
|
"@release-it/conventional-changelog": "^10.0.6",
|
|
73
|
-
"@types/node": "^25.9.1",
|
|
74
76
|
"@types/react": "^19.2.0",
|
|
75
77
|
"commitlint": "^20.5.0",
|
|
76
78
|
"del-cli": "^7.0.0",
|
|
@@ -8,20 +8,78 @@ export type CardInfo = {
|
|
|
8
8
|
serialNumber: string | null;
|
|
9
9
|
pinRetryCount: number | null;
|
|
10
10
|
isNewCard: boolean | null;
|
|
11
|
+
isBackup: boolean | null;
|
|
11
12
|
};
|
|
12
13
|
|
|
14
|
+
export type CallbackError = { code: number; message: string | null };
|
|
15
|
+
|
|
16
|
+
/** App-layer result type (same pattern as react-native-lite-card PromiseResult). */
|
|
17
|
+
export type PromiseResult<T> = {
|
|
18
|
+
error: CallbackError | null;
|
|
19
|
+
data: T | null;
|
|
20
|
+
cardInfo: CardInfo | null;
|
|
21
|
+
resultCode: number;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type CardOperationResult<T> = PromiseResult<T>;
|
|
25
|
+
|
|
13
26
|
export interface Spec extends TurboModule {
|
|
27
|
+
/** Waits for user to tap the backup card (Android), then reads card info. */
|
|
14
28
|
getCardInfo(): Promise<CardInfo | null>;
|
|
29
|
+
/** Cancels an in-flight wait for NFC tap (Android). */
|
|
30
|
+
cancelNfcWait(): void;
|
|
31
|
+
/** Android: hardware NFC, system switch, MIUI permission. iOS: not implemented yet. */
|
|
32
|
+
checkNFCPermission(): Promise<boolean>;
|
|
33
|
+
/** Android: opens system NFC settings. iOS: not implemented yet. */
|
|
34
|
+
intoSetting(): void;
|
|
15
35
|
resetCard(): Promise<Boolean>;
|
|
16
|
-
activateCard(
|
|
36
|
+
activateCard(
|
|
37
|
+
pwd: string,
|
|
38
|
+
serialNumber: string
|
|
39
|
+
): Promise<{
|
|
40
|
+
error: CallbackError | null;
|
|
41
|
+
cardInfo: CardInfo | null;
|
|
42
|
+
resultCode: number;
|
|
43
|
+
data: string | null;
|
|
44
|
+
}>;
|
|
17
45
|
changePin(oldPin: string, newPin: string): Promise<Boolean>;
|
|
18
|
-
checkSlotEmpty(
|
|
46
|
+
checkSlotEmpty(
|
|
47
|
+
slotId: number,
|
|
48
|
+
pwd: string
|
|
49
|
+
): Promise<{
|
|
50
|
+
error: CallbackError | null;
|
|
51
|
+
cardInfo: CardInfo | null;
|
|
52
|
+
resultCode: number;
|
|
53
|
+
data: string | null;
|
|
54
|
+
}>;
|
|
19
55
|
writeSlot(
|
|
20
56
|
slotIndex: number,
|
|
21
57
|
data: Array<number>,
|
|
22
58
|
pwd: string
|
|
23
|
-
): Promise<
|
|
24
|
-
|
|
59
|
+
): Promise<{
|
|
60
|
+
error: CallbackError | null;
|
|
61
|
+
cardInfo: CardInfo | null;
|
|
62
|
+
resultCode: number;
|
|
63
|
+
data: string | null;
|
|
64
|
+
}>;
|
|
65
|
+
readSlot(
|
|
66
|
+
slotIndex: number,
|
|
67
|
+
pwd: string
|
|
68
|
+
): Promise<{
|
|
69
|
+
error: CallbackError | null;
|
|
70
|
+
cardInfo: CardInfo | null;
|
|
71
|
+
resultCode: number;
|
|
72
|
+
data: string | null;
|
|
73
|
+
}>;
|
|
74
|
+
deleteSlot(
|
|
75
|
+
slotIndex: number,
|
|
76
|
+
pwd: string
|
|
77
|
+
): Promise<{
|
|
78
|
+
error: CallbackError | null;
|
|
79
|
+
cardInfo: CardInfo | null;
|
|
80
|
+
resultCode: number;
|
|
81
|
+
data: string | null;
|
|
82
|
+
}>;
|
|
25
83
|
|
|
26
84
|
readonly onApduLog: CodegenTypes.EventEmitter<{
|
|
27
85
|
message: string;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import BackupCardSdk from './NativeBackupCardSdk';
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CallbackError,
|
|
5
|
+
CardInfo,
|
|
6
|
+
CardOperationResult,
|
|
7
|
+
} from './NativeBackupCardSdk';
|
|
8
|
+
|
|
9
|
+
type NativeCardOperationResult = {
|
|
10
|
+
error: CallbackError | null;
|
|
11
|
+
cardInfo: CardInfo | null;
|
|
12
|
+
resultCode: number;
|
|
13
|
+
data: string | null;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function withoutData(
|
|
17
|
+
result: NativeCardOperationResult
|
|
18
|
+
): CardOperationResult<null> {
|
|
19
|
+
return {
|
|
20
|
+
error: result.error,
|
|
21
|
+
cardInfo: result.cardInfo,
|
|
22
|
+
resultCode: result.resultCode,
|
|
23
|
+
data: null,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export async function activateCard(
|
|
28
|
+
pwd: string,
|
|
29
|
+
serialNumber: string
|
|
30
|
+
): Promise<CardOperationResult<null>> {
|
|
31
|
+
return withoutData(await BackupCardSdk.activateCard(pwd, serialNumber));
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function checkSlotEmpty(
|
|
35
|
+
slotId: number,
|
|
36
|
+
pwd: string
|
|
37
|
+
): Promise<CardOperationResult<null>> {
|
|
38
|
+
return withoutData(await BackupCardSdk.checkSlotEmpty(slotId, pwd));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function writeSlot(
|
|
42
|
+
slotIndex: number,
|
|
43
|
+
data: Array<number>,
|
|
44
|
+
pwd: string
|
|
45
|
+
): Promise<CardOperationResult<null>> {
|
|
46
|
+
return withoutData(await BackupCardSdk.writeSlot(slotIndex, data, pwd));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function readSlot(
|
|
50
|
+
slotIndex: number,
|
|
51
|
+
pwd: string
|
|
52
|
+
): Promise<CardOperationResult<string>> {
|
|
53
|
+
return BackupCardSdk.readSlot(slotIndex, pwd);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export async function deleteSlot(
|
|
57
|
+
slotIndex: number,
|
|
58
|
+
pwd: string
|
|
59
|
+
): Promise<CardOperationResult<null>> {
|
|
60
|
+
return withoutData(await BackupCardSdk.deleteSlot(slotIndex, pwd));
|
|
61
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import BackupCardSdk from './NativeBackupCardSdk';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type {
|
|
3
|
+
CardInfo,
|
|
4
|
+
CardOperationResult,
|
|
5
|
+
PromiseResult,
|
|
6
|
+
} from './NativeBackupCardSdk';
|
|
7
|
+
|
|
8
|
+
export type { CardInfo, CardOperationResult, PromiseResult };
|
|
9
|
+
export type { CallbackError } from './nfc';
|
|
10
|
+
export {
|
|
11
|
+
CardErrors,
|
|
12
|
+
cancelNfcWait,
|
|
13
|
+
checkNFCPermission,
|
|
14
|
+
intoSetting,
|
|
15
|
+
} from './nfc';
|
|
16
|
+
export {
|
|
17
|
+
activateCard,
|
|
18
|
+
checkSlotEmpty,
|
|
19
|
+
deleteSlot,
|
|
20
|
+
readSlot,
|
|
21
|
+
writeSlot,
|
|
22
|
+
} from './cardOperations';
|
|
23
|
+
|
|
4
24
|
export default BackupCardSdk;
|
package/src/nfc.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Platform } from 'react-native';
|
|
2
|
+
|
|
3
|
+
import BackupCardSdk from './NativeBackupCardSdk';
|
|
4
|
+
|
|
5
|
+
import type { PromiseResult } from './NativeBackupCardSdk';
|
|
6
|
+
|
|
7
|
+
export type CallbackError = { code: number; message: string | null } | null;
|
|
8
|
+
|
|
9
|
+
/** Same error codes as @digitalshieldfe/react-native-lite-card for NFC checks. */
|
|
10
|
+
export enum CardErrors {
|
|
11
|
+
InitChannel = 1000,
|
|
12
|
+
NotExistsNFC = 1001,
|
|
13
|
+
NotEnableNFC = 1002,
|
|
14
|
+
NotNFCPermission = 1003,
|
|
15
|
+
|
|
16
|
+
ConnectionFail = 2001,
|
|
17
|
+
NotSameNFCLite = 2002,
|
|
18
|
+
ActivateCardFailed = 2003,
|
|
19
|
+
NotSupportedCard = 2004,
|
|
20
|
+
PasswordWrong = 2005,
|
|
21
|
+
NotSetPassword = 2006,
|
|
22
|
+
CardLock = 2007,
|
|
23
|
+
NotInitializedError = 2008,
|
|
24
|
+
|
|
25
|
+
InitializedError = 4001,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function parseTurboModuleError(error: unknown): CallbackError {
|
|
29
|
+
const err = error as {
|
|
30
|
+
message?: string;
|
|
31
|
+
userInfo?: { code?: number; message?: string };
|
|
32
|
+
};
|
|
33
|
+
const code = err?.userInfo?.code;
|
|
34
|
+
if (typeof code === 'number') {
|
|
35
|
+
return { code, message: err.userInfo?.message ?? err.message ?? null };
|
|
36
|
+
}
|
|
37
|
+
return { code: CardErrors.InitChannel, message: err?.message ?? null };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Android only for now; iOS will be added later. */
|
|
41
|
+
export function checkNFCPermission(): Promise<PromiseResult<boolean>> {
|
|
42
|
+
if (Platform.OS !== 'android') {
|
|
43
|
+
return Promise.resolve({
|
|
44
|
+
error: {
|
|
45
|
+
code: CardErrors.InitChannel,
|
|
46
|
+
message: 'checkNFCPermission is not implemented on iOS yet',
|
|
47
|
+
},
|
|
48
|
+
data: null,
|
|
49
|
+
cardInfo: null,
|
|
50
|
+
resultCode: -1,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return BackupCardSdk.checkNFCPermission()
|
|
54
|
+
.then(() => ({ error: null, data: true, cardInfo: null, resultCode: 0 }))
|
|
55
|
+
.catch((error: unknown) => ({
|
|
56
|
+
error: parseTurboModuleError(error),
|
|
57
|
+
data: null,
|
|
58
|
+
cardInfo: null,
|
|
59
|
+
resultCode: -1,
|
|
60
|
+
}));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** Android only for now; iOS will be added later. */
|
|
64
|
+
export function intoSetting(): void {
|
|
65
|
+
if (Platform.OS !== 'android') {
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
BackupCardSdk.intoSetting();
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Call when user dismisses the "tap card" UI to stop waiting. Android only. */
|
|
72
|
+
export function cancelNfcWait(): void {
|
|
73
|
+
BackupCardSdk.cancelNfcWait();
|
|
74
|
+
}
|
|
File without changes
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
# Add project specific ProGuard rules here.
|
|
2
|
-
# You can control the set of applied configuration files using the
|
|
3
|
-
# proguardFiles setting in build.gradle.
|
|
4
|
-
#
|
|
5
|
-
# For more details, see
|
|
6
|
-
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
7
|
-
|
|
8
|
-
# If your project uses WebView with JS, uncomment the following
|
|
9
|
-
# and specify the fully qualified class name to the JavaScript interface
|
|
10
|
-
# class:
|
|
11
|
-
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
12
|
-
# public *;
|
|
13
|
-
#}
|
|
14
|
-
|
|
15
|
-
# Uncomment this to preserve the line number information for
|
|
16
|
-
# debugging stack traces.
|
|
17
|
-
#-keepattributes SourceFile,LineNumberTable
|
|
18
|
-
|
|
19
|
-
# If you keep the line number information, uncomment this to
|
|
20
|
-
# hide the original source file name.
|
|
21
|
-
#-renamesourcefileattribute SourceFile
|