react-native-quick-crypto 0.7.11 → 1.0.0-beta.10
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/QuickCrypto.podspec +47 -0
- package/README.md +6 -4
- package/android/CMakeLists.txt +26 -55
- package/android/build.gradle +70 -112
- package/android/gradle.properties +3 -3
- package/android/src/main/cpp/cpp-adapter.cpp +3 -64
- package/android/src/main/java/com/margelo/nitro/quickcrypto/QuickCryptoPackage.java +43 -0
- package/cpp/ed25519/HybridEdKeyPair.cpp +268 -0
- package/cpp/ed25519/HybridEdKeyPair.hpp +85 -0
- package/cpp/pbkdf2/HybridPbkdf2.cpp +72 -0
- package/cpp/pbkdf2/HybridPbkdf2.hpp +35 -0
- package/cpp/random/HybridRandom.cpp +59 -0
- package/cpp/random/HybridRandom.hpp +33 -0
- package/cpp/utils/Utils.hpp +20 -0
- package/lib/commonjs/ed.js +42 -0
- package/lib/commonjs/ed.js.map +1 -0
- package/lib/commonjs/index.js +90 -39
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/keys/classes.js +191 -0
- package/lib/commonjs/keys/classes.js.map +1 -0
- package/lib/commonjs/keys/generateKeyPair.js +148 -0
- package/lib/commonjs/keys/generateKeyPair.js.map +1 -0
- package/lib/commonjs/keys/index.js +62 -0
- package/lib/commonjs/keys/index.js.map +1 -0
- package/lib/commonjs/keys/signVerify.js +41 -0
- package/lib/commonjs/keys/signVerify.js.map +1 -0
- package/lib/commonjs/keys/utils.js +118 -0
- package/lib/commonjs/keys/utils.js.map +1 -0
- package/lib/commonjs/pbkdf2.js +29 -19
- package/lib/commonjs/pbkdf2.js.map +1 -1
- package/lib/commonjs/random.js +27 -11
- package/lib/commonjs/random.js.map +1 -1
- package/lib/commonjs/{NativeQuickCrypto/aes.js → specs/edKeyPair.nitro.js} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/aes.js.map → specs/edKeyPair.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/keygen.js → specs/keyObjectHandle.nitro.js} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/hash.js.map → specs/keyObjectHandle.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/rsa.js → specs/pbkdf2.nitro.js} +1 -1
- package/lib/{module/NativeQuickCrypto/aes.js.map → commonjs/specs/pbkdf2.nitro.js.map} +1 -1
- package/lib/commonjs/{NativeQuickCrypto/webcrypto.js → specs/random.nitro.js} +1 -1
- package/lib/{module/NativeQuickCrypto/rsa.js.map → commonjs/specs/random.nitro.js.map} +1 -1
- package/lib/commonjs/utils/conversion.js +117 -0
- package/lib/commonjs/utils/conversion.js.map +1 -0
- package/lib/commonjs/utils/errors.js +14 -0
- package/lib/commonjs/utils/errors.js.map +1 -0
- package/lib/commonjs/{Hashnames.js → utils/hashnames.js} +2 -5
- package/lib/commonjs/utils/hashnames.js.map +1 -0
- package/lib/commonjs/utils/index.js +61 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/types.js +40 -0
- package/lib/commonjs/utils/types.js.map +1 -0
- package/lib/commonjs/utils/validation.js +25 -0
- package/lib/commonjs/utils/validation.js.map +1 -0
- package/lib/module/ed.js +37 -0
- package/lib/module/ed.js.map +1 -0
- package/lib/module/index.js +44 -37
- package/lib/module/index.js.map +1 -1
- package/lib/module/keys/classes.js +182 -0
- package/lib/module/keys/classes.js.map +1 -0
- package/lib/module/keys/generateKeyPair.js +148 -0
- package/lib/module/keys/generateKeyPair.js.map +1 -0
- package/lib/module/keys/index.js +29 -0
- package/lib/module/keys/index.js.map +1 -0
- package/lib/module/keys/signVerify.js +41 -0
- package/lib/module/keys/signVerify.js.map +1 -0
- package/lib/module/keys/utils.js +110 -0
- package/lib/module/keys/utils.js.map +1 -0
- package/lib/module/pbkdf2.js +17 -7
- package/lib/module/pbkdf2.js.map +1 -1
- package/lib/module/random.js +26 -10
- package/lib/module/random.js.map +1 -1
- package/lib/module/specs/edKeyPair.nitro.js +4 -0
- package/lib/{commonjs/NativeQuickCrypto/rsa.js.map → module/specs/edKeyPair.nitro.js.map} +1 -1
- package/lib/module/specs/keyObjectHandle.nitro.js +4 -0
- package/lib/{commonjs/NativeQuickCrypto/hmac.js.map → module/specs/keyObjectHandle.nitro.js.map} +1 -1
- package/lib/module/specs/pbkdf2.nitro.js +4 -0
- package/lib/module/specs/pbkdf2.nitro.js.map +1 -0
- package/lib/module/specs/random.nitro.js +4 -0
- package/lib/module/specs/random.nitro.js.map +1 -0
- package/lib/module/utils/conversion.js +107 -0
- package/lib/module/utils/conversion.js.map +1 -0
- package/lib/module/utils/errors.js +10 -0
- package/lib/module/utils/errors.js.map +1 -0
- package/lib/module/{Hashnames.js → utils/hashnames.js} +2 -5
- package/lib/module/utils/hashnames.js.map +1 -0
- package/lib/module/utils/index.js +8 -0
- package/lib/module/utils/index.js.map +1 -0
- package/lib/module/utils/types.js +42 -0
- package/lib/module/utils/types.js.map +1 -0
- package/lib/module/utils/validation.js +19 -0
- package/lib/module/utils/validation.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/lib/typescript/ed.d.ts +17 -0
- package/lib/typescript/ed.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +74 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/keys/classes.d.ts +38 -0
- package/lib/typescript/keys/classes.d.ts.map +1 -0
- package/lib/typescript/keys/generateKeyPair.d.ts +1 -0
- package/lib/typescript/keys/generateKeyPair.d.ts.map +1 -0
- package/lib/typescript/keys/index.d.ts +4 -0
- package/lib/typescript/keys/index.d.ts.map +1 -0
- package/lib/typescript/keys/signVerify.d.ts +1 -0
- package/lib/typescript/keys/signVerify.d.ts.map +1 -0
- package/lib/typescript/keys/utils.d.ts +32 -0
- package/lib/typescript/keys/utils.d.ts.map +1 -0
- package/lib/typescript/{src/pbkdf2.d.ts → pbkdf2.d.ts} +4 -3
- package/lib/typescript/pbkdf2.d.ts.map +1 -0
- package/lib/typescript/{src/random.d.ts → random.d.ts} +4 -4
- package/lib/typescript/random.d.ts.map +1 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts +16 -0
- package/lib/typescript/specs/edKeyPair.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts +15 -0
- package/lib/typescript/specs/keyObjectHandle.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts +9 -0
- package/lib/typescript/specs/pbkdf2.nitro.d.ts.map +1 -0
- package/lib/typescript/specs/random.nitro.d.ts +9 -0
- package/lib/typescript/specs/random.nitro.d.ts.map +1 -0
- package/lib/typescript/utils/conversion.d.ts +25 -0
- package/lib/typescript/utils/conversion.d.ts.map +1 -0
- package/lib/typescript/utils/errors.d.ts +7 -0
- package/lib/typescript/utils/errors.d.ts.map +1 -0
- package/lib/typescript/{src/Hashnames.d.ts → utils/hashnames.d.ts} +3 -3
- package/lib/typescript/utils/hashnames.d.ts.map +1 -0
- package/lib/typescript/utils/index.d.ts +6 -0
- package/lib/typescript/utils/index.d.ts.map +1 -0
- package/lib/typescript/utils/types.d.ts +162 -0
- package/lib/typescript/utils/types.d.ts.map +1 -0
- package/lib/typescript/utils/validation.d.ts +8 -0
- package/lib/typescript/utils/validation.d.ts.map +1 -0
- package/nitrogen/generated/android/QuickCrypto+autolinking.cmake +65 -0
- package/nitrogen/generated/android/QuickCrypto+autolinking.gradle +27 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.cpp +64 -0
- package/nitrogen/generated/android/QuickCryptoOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/QuickCrypto+autolinking.rb +58 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/QuickCrypto-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.mm +55 -0
- package/nitrogen/generated/ios/QuickCryptoAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/CFRGKeyPairType.hpp +86 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.cpp +29 -0
- package/nitrogen/generated/shared/c++/HybridEdKeyPairSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.cpp +27 -0
- package/nitrogen/generated/shared/c++/HybridKeyObjectHandleSpec.hpp +93 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridPbkdf2Spec.hpp +66 -0
- package/nitrogen/generated/shared/c++/HybridRandomSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridRandomSpec.hpp +65 -0
- package/nitrogen/generated/shared/c++/JWK.hpp +162 -0
- package/nitrogen/generated/shared/c++/JWKkty.hpp +86 -0
- package/nitrogen/generated/shared/c++/JWKuse.hpp +78 -0
- package/nitrogen/generated/shared/c++/KFormatType.hpp +65 -0
- package/nitrogen/generated/shared/c++/KeyDetail.hpp +93 -0
- package/nitrogen/generated/shared/c++/KeyEncoding.hpp +66 -0
- package/nitrogen/generated/shared/c++/KeyType.hpp +65 -0
- package/nitrogen/generated/shared/c++/KeyUsage.hpp +102 -0
- package/nitrogen/generated/shared/c++/NamedCurve.hpp +82 -0
- package/package.json +57 -51
- package/src/ed.ts +79 -0
- package/src/index.ts +43 -47
- package/src/keys/classes.ts +211 -0
- package/src/keys/generateKeyPair.ts +146 -0
- package/src/keys/index.ts +42 -0
- package/src/keys/signVerify.ts +39 -0
- package/src/keys/utils.ts +184 -0
- package/src/pbkdf2.ts +26 -15
- package/src/random.ts +33 -20
- package/src/specs/edKeyPair.nitro.ts +41 -0
- package/src/specs/keyObjectHandle.nitro.ts +32 -0
- package/src/{NativeQuickCrypto/pbkdf2.ts → specs/pbkdf2.nitro.ts} +8 -6
- package/src/specs/random.nitro.ts +14 -0
- package/src/utils/conversion.ts +123 -0
- package/src/utils/errors.ts +15 -0
- package/src/{Hashnames.ts → utils/hashnames.ts} +4 -7
- package/src/utils/index.ts +5 -0
- package/src/utils/types.ts +275 -0
- package/src/utils/validation.ts +35 -0
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoModule.java +0 -70
- package/android/src/main/java/com/margelo/quickcrypto/QuickCryptoPackage.java +0 -25
- package/cpp/Cipher/MGLCipherHostObject.cpp +0 -663
- package/cpp/Cipher/MGLCipherHostObject.h +0 -90
- package/cpp/Cipher/MGLCreateCipherInstaller.cpp +0 -75
- package/cpp/Cipher/MGLCreateCipherInstaller.h +0 -22
- package/cpp/Cipher/MGLCreateDecipherInstaller.cpp +0 -77
- package/cpp/Cipher/MGLCreateDecipherInstaller.h +0 -17
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.cpp +0 -134
- package/cpp/Cipher/MGLGenerateKeyPairInstaller.h +0 -35
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.cpp +0 -63
- package/cpp/Cipher/MGLGenerateKeyPairSyncInstaller.h +0 -37
- package/cpp/Cipher/MGLPublicCipher.h +0 -124
- package/cpp/Cipher/MGLPublicCipherInstaller.h +0 -107
- package/cpp/Cipher/MGLRsa.cpp +0 -573
- package/cpp/Cipher/MGLRsa.h +0 -109
- package/cpp/HMAC/MGLHmacHostObject.cpp +0 -95
- package/cpp/HMAC/MGLHmacHostObject.h +0 -39
- package/cpp/HMAC/MGLHmacInstaller.cpp +0 -43
- package/cpp/HMAC/MGLHmacInstaller.h +0 -20
- package/cpp/Hash/MGLHashHostObject.cpp +0 -147
- package/cpp/Hash/MGLHashHostObject.h +0 -53
- package/cpp/Hash/MGLHashInstaller.cpp +0 -44
- package/cpp/Hash/MGLHashInstaller.h +0 -20
- package/cpp/JSIUtils/MGLJSIMacros.h +0 -110
- package/cpp/JSIUtils/MGLJSIUtils.h +0 -41
- package/cpp/JSIUtils/MGLSmartHostObject.cpp +0 -43
- package/cpp/JSIUtils/MGLSmartHostObject.h +0 -46
- package/cpp/JSIUtils/MGLThreadAwareHostObject.cpp +0 -24
- package/cpp/JSIUtils/MGLThreadAwareHostObject.h +0 -43
- package/cpp/JSIUtils/MGLTypedArray.cpp +0 -352
- package/cpp/JSIUtils/MGLTypedArray.h +0 -179
- package/cpp/MGLKeys.cpp +0 -1426
- package/cpp/MGLKeys.h +0 -203
- package/cpp/MGLQuickCryptoHostObject.cpp +0 -127
- package/cpp/MGLQuickCryptoHostObject.h +0 -30
- package/cpp/Random/MGLRandomHostObject.cpp +0 -96
- package/cpp/Random/MGLRandomHostObject.h +0 -27
- package/cpp/Sig/MGLSignHostObjects.cpp +0 -757
- package/cpp/Sig/MGLSignHostObjects.h +0 -128
- package/cpp/Sig/MGLSignInstaller.cpp +0 -24
- package/cpp/Sig/MGLSignInstaller.h +0 -29
- package/cpp/Sig/MGLVerifyInstaller.cpp +0 -24
- package/cpp/Sig/MGLVerifyInstaller.h +0 -22
- package/cpp/Utils/MGLDispatchQueue.cpp +0 -75
- package/cpp/Utils/MGLDispatchQueue.h +0 -55
- package/cpp/Utils/MGLUtils.cpp +0 -295
- package/cpp/Utils/MGLUtils.h +0 -358
- package/cpp/Utils/base64.h +0 -320
- package/cpp/Utils/logs.h +0 -38
- package/cpp/Utils/node.h +0 -13
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.cpp +0 -164
- package/cpp/fastpbkdf2/MGLPbkdf2HostObject.h +0 -29
- package/cpp/webcrypto/MGLWebCrypto.cpp +0 -125
- package/cpp/webcrypto/MGLWebCrypto.h +0 -32
- package/cpp/webcrypto/crypto_aes.cpp +0 -516
- package/cpp/webcrypto/crypto_aes.h +0 -79
- package/cpp/webcrypto/crypto_ec.cpp +0 -424
- package/cpp/webcrypto/crypto_ec.h +0 -78
- package/cpp/webcrypto/crypto_keygen.cpp +0 -86
- package/cpp/webcrypto/crypto_keygen.h +0 -38
- package/ios/QuickCrypto.xcodeproj/project.pbxproj +0 -274
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/QuickCrypto.xcodeproj/project.xcworkspace/xcuserdata/brad.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- package/ios/QuickCrypto.xcodeproj/xcuserdata/brad.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
- package/ios/QuickCryptoModule.h +0 -5
- package/ios/QuickCryptoModule.mm +0 -57
- package/lib/commonjs/Algorithms.js +0 -224
- package/lib/commonjs/Algorithms.js.map +0 -1
- package/lib/commonjs/Cipher.js +0 -504
- package/lib/commonjs/Cipher.js.map +0 -1
- package/lib/commonjs/Hash.js +0 -102
- package/lib/commonjs/Hash.js.map +0 -1
- package/lib/commonjs/Hashnames.js.map +0 -1
- package/lib/commonjs/Hmac.js +0 -81
- package/lib/commonjs/Hmac.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/Cipher.js +0 -30
- package/lib/commonjs/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js +0 -59
- package/lib/commonjs/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/hash.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/hmac.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/random.js +0 -2
- package/lib/commonjs/NativeQuickCrypto/random.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/sig.js +0 -19
- package/lib/commonjs/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/commonjs/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/commonjs/Utils.js +0 -437
- package/lib/commonjs/Utils.js.map +0 -1
- package/lib/commonjs/aes.js +0 -282
- package/lib/commonjs/aes.js.map +0 -1
- package/lib/commonjs/constants.js +0 -85
- package/lib/commonjs/constants.js.map +0 -1
- package/lib/commonjs/ec.js +0 -275
- package/lib/commonjs/ec.js.map +0 -1
- package/lib/commonjs/keygen.js +0 -58
- package/lib/commonjs/keygen.js.map +0 -1
- package/lib/commonjs/keys.js +0 -497
- package/lib/commonjs/keys.js.map +0 -1
- package/lib/commonjs/rsa.js +0 -248
- package/lib/commonjs/rsa.js.map +0 -1
- package/lib/commonjs/sig.js +0 -128
- package/lib/commonjs/sig.js.map +0 -1
- package/lib/commonjs/subtle.js +0 -450
- package/lib/commonjs/subtle.js.map +0 -1
- package/lib/commonjs/webcrypto.js +0 -14
- package/lib/commonjs/webcrypto.js.map +0 -1
- package/lib/module/Algorithms.js +0 -219
- package/lib/module/Algorithms.js.map +0 -1
- package/lib/module/Cipher.js +0 -493
- package/lib/module/Cipher.js.map +0 -1
- package/lib/module/Hash.js +0 -96
- package/lib/module/Hash.js.map +0 -1
- package/lib/module/Hashnames.js.map +0 -1
- package/lib/module/Hmac.js +0 -76
- package/lib/module/Hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/Cipher.js +0 -26
- package/lib/module/NativeQuickCrypto/Cipher.js.map +0 -1
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js +0 -56
- package/lib/module/NativeQuickCrypto/NativeQuickCrypto.js.map +0 -1
- package/lib/module/NativeQuickCrypto/aes.js +0 -4
- package/lib/module/NativeQuickCrypto/hash.js +0 -2
- package/lib/module/NativeQuickCrypto/hash.js.map +0 -1
- package/lib/module/NativeQuickCrypto/hmac.js +0 -2
- package/lib/module/NativeQuickCrypto/hmac.js.map +0 -1
- package/lib/module/NativeQuickCrypto/keygen.js +0 -4
- package/lib/module/NativeQuickCrypto/keygen.js.map +0 -1
- package/lib/module/NativeQuickCrypto/pbkdf2.js +0 -2
- package/lib/module/NativeQuickCrypto/pbkdf2.js.map +0 -1
- package/lib/module/NativeQuickCrypto/random.js +0 -2
- package/lib/module/NativeQuickCrypto/random.js.map +0 -1
- package/lib/module/NativeQuickCrypto/rsa.js +0 -4
- package/lib/module/NativeQuickCrypto/sig.js +0 -17
- package/lib/module/NativeQuickCrypto/sig.js.map +0 -1
- package/lib/module/NativeQuickCrypto/webcrypto.js +0 -4
- package/lib/module/NativeQuickCrypto/webcrypto.js.map +0 -1
- package/lib/module/Utils.js +0 -369
- package/lib/module/Utils.js.map +0 -1
- package/lib/module/aes.js +0 -275
- package/lib/module/aes.js.map +0 -1
- package/lib/module/constants.js +0 -81
- package/lib/module/constants.js.map +0 -1
- package/lib/module/ec.js +0 -266
- package/lib/module/ec.js.map +0 -1
- package/lib/module/keygen.js +0 -51
- package/lib/module/keygen.js.map +0 -1
- package/lib/module/keys.js +0 -482
- package/lib/module/keys.js.map +0 -1
- package/lib/module/rsa.js +0 -242
- package/lib/module/rsa.js.map +0 -1
- package/lib/module/sig.js +0 -123
- package/lib/module/sig.js.map +0 -1
- package/lib/module/subtle.js +0 -445
- package/lib/module/subtle.js.map +0 -1
- package/lib/module/webcrypto.js +0 -10
- package/lib/module/webcrypto.js.map +0 -1
- package/lib/typescript/src/Algorithms.d.ts +0 -4
- package/lib/typescript/src/Algorithms.d.ts.map +0 -1
- package/lib/typescript/src/Cipher.d.ts +0 -85
- package/lib/typescript/src/Cipher.d.ts.map +0 -1
- package/lib/typescript/src/Hash.d.ts +0 -44
- package/lib/typescript/src/Hash.d.ts.map +0 -1
- package/lib/typescript/src/Hashnames.d.ts.map +0 -1
- package/lib/typescript/src/Hmac.d.ts +0 -37
- package/lib/typescript/src/Hmac.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/Cipher.d.ts +0 -44
- package/lib/typescript/src/NativeQuickCrypto/Cipher.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/NativeQuickCrypto.d.ts +0 -33
- package/lib/typescript/src/NativeQuickCrypto/NativeQuickCrypto.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/aes.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/aes.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/hash.d.ts +0 -7
- package/lib/typescript/src/NativeQuickCrypto/hash.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/hmac.d.ts +0 -6
- package/lib/typescript/src/NativeQuickCrypto/hmac.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/keygen.d.ts +0 -4
- package/lib/typescript/src/NativeQuickCrypto/keygen.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/pbkdf2.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/random.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/random.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/rsa.d.ts +0 -5
- package/lib/typescript/src/NativeQuickCrypto/rsa.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/sig.d.ts +0 -23
- package/lib/typescript/src/NativeQuickCrypto/sig.d.ts.map +0 -1
- package/lib/typescript/src/NativeQuickCrypto/webcrypto.d.ts +0 -40
- package/lib/typescript/src/NativeQuickCrypto/webcrypto.d.ts.map +0 -1
- package/lib/typescript/src/Utils.d.ts +0 -71
- package/lib/typescript/src/Utils.d.ts.map +0 -1
- package/lib/typescript/src/aes.d.ts +0 -22
- package/lib/typescript/src/aes.d.ts.map +0 -1
- package/lib/typescript/src/constants.d.ts +0 -76
- package/lib/typescript/src/constants.d.ts.map +0 -1
- package/lib/typescript/src/ec.d.ts +0 -7
- package/lib/typescript/src/ec.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -139
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/lib/typescript/src/keygen.d.ts +0 -6
- package/lib/typescript/src/keygen.d.ts.map +0 -1
- package/lib/typescript/src/keys.d.ts +0 -211
- package/lib/typescript/src/keys.d.ts.map +0 -1
- package/lib/typescript/src/pbkdf2.d.ts.map +0 -1
- package/lib/typescript/src/random.d.ts.map +0 -1
- package/lib/typescript/src/rsa.d.ts +0 -12
- package/lib/typescript/src/rsa.d.ts.map +0 -1
- package/lib/typescript/src/sig.d.ts +0 -21
- package/lib/typescript/src/sig.d.ts.map +0 -1
- package/lib/typescript/src/subtle.d.ts +0 -15
- package/lib/typescript/src/subtle.d.ts.map +0 -1
- package/lib/typescript/src/webcrypto.d.ts +0 -9
- package/lib/typescript/src/webcrypto.d.ts.map +0 -1
- package/react-native-quick-crypto.podspec +0 -40
- package/src/Algorithms.ts +0 -247
- package/src/Cipher.ts +0 -890
- package/src/Hash.ts +0 -139
- package/src/Hmac.ts +0 -107
- package/src/NativeQuickCrypto/Cipher.ts +0 -103
- package/src/NativeQuickCrypto/NativeQuickCrypto.ts +0 -106
- package/src/NativeQuickCrypto/aes.ts +0 -14
- package/src/NativeQuickCrypto/hash.ts +0 -10
- package/src/NativeQuickCrypto/hmac.ts +0 -9
- package/src/NativeQuickCrypto/keygen.ts +0 -7
- package/src/NativeQuickCrypto/random.ts +0 -12
- package/src/NativeQuickCrypto/rsa.ts +0 -12
- package/src/NativeQuickCrypto/sig.ts +0 -46
- package/src/NativeQuickCrypto/webcrypto.ts +0 -73
- package/src/Utils.ts +0 -628
- package/src/aes.ts +0 -402
- package/src/constants.ts +0 -79
- package/src/ec.ts +0 -374
- package/src/keygen.ts +0 -80
- package/src/keys.ts +0 -797
- package/src/rsa.ts +0 -372
- package/src/sig.ts +0 -163
- package/src/subtle.ts +0 -643
- package/src/webcrypto.ts +0 -8
- /package/android/src/main/{AndroidManifestNew.xml → AndroidManifest.xml} +0 -0
- /package/{cpp → deps}/fastpbkdf2/fastpbkdf2.c +0 -0
- /package/{cpp → deps}/fastpbkdf2/fastpbkdf2.h +0 -0
package/package.json
CHANGED
|
@@ -1,33 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-quick-crypto",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.10",
|
|
4
4
|
"description": "A fast implementation of Node's `crypto` module written in C/C++ JSI",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
7
7
|
"module": "lib/module/index",
|
|
8
|
-
"types": "lib/typescript/
|
|
9
|
-
"react-native": "
|
|
8
|
+
"types": "lib/typescript/index.d.ts",
|
|
9
|
+
"react-native": "src/index",
|
|
10
10
|
"source": "src/index",
|
|
11
|
-
"files": [
|
|
12
|
-
"src",
|
|
13
|
-
"lib",
|
|
14
|
-
"android/src",
|
|
15
|
-
"android/build.gradle",
|
|
16
|
-
"android/gradle.properties",
|
|
17
|
-
"android/CMakeLists.txt",
|
|
18
|
-
"ios",
|
|
19
|
-
"cpp",
|
|
20
|
-
"react-native-quick-crypto.podspec",
|
|
21
|
-
"!lib/typescript/example",
|
|
22
|
-
"!android/build",
|
|
23
|
-
"!ios/build",
|
|
24
|
-
"!**/__tests__",
|
|
25
|
-
"!**/__fixtures__",
|
|
26
|
-
"!**/__mocks__"
|
|
27
|
-
],
|
|
28
11
|
"scripts": {
|
|
29
12
|
"clean": "del-cli android/build lib",
|
|
30
|
-
"deepclean": "del-cli node_modules",
|
|
31
13
|
"tsc": "tsc --noEmit",
|
|
32
14
|
"typescript": "tsc --noEmit",
|
|
33
15
|
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
@@ -36,8 +18,28 @@
|
|
|
36
18
|
"format:fix": "prettier --write \"**/*.{js,ts,tsx}\"",
|
|
37
19
|
"prepare": "bun clean && bun tsc && bob build",
|
|
38
20
|
"release": "release-it",
|
|
21
|
+
"specs": "nitro-codegen",
|
|
39
22
|
"test": "jest"
|
|
40
23
|
},
|
|
24
|
+
"files": [
|
|
25
|
+
"src",
|
|
26
|
+
"lib",
|
|
27
|
+
"android/build.gradle",
|
|
28
|
+
"android/gradle.properties",
|
|
29
|
+
"android/CMakeLists.txt",
|
|
30
|
+
"android/src",
|
|
31
|
+
"ios",
|
|
32
|
+
"cpp",
|
|
33
|
+
"deps",
|
|
34
|
+
"nitrogen",
|
|
35
|
+
"react-native.config.js",
|
|
36
|
+
"app.plugin.js",
|
|
37
|
+
"*.podspec",
|
|
38
|
+
"README.md",
|
|
39
|
+
"!**/__tests__",
|
|
40
|
+
"!**/__fixtures__",
|
|
41
|
+
"!**/__mocks__"
|
|
42
|
+
],
|
|
41
43
|
"keywords": [
|
|
42
44
|
"react-native",
|
|
43
45
|
"ios",
|
|
@@ -66,35 +68,37 @@
|
|
|
66
68
|
"registry": "https://registry.npmjs.org/"
|
|
67
69
|
},
|
|
68
70
|
"dependencies": {
|
|
69
|
-
"@craftzdog/react-native-buffer": "
|
|
70
|
-
"events": "
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
71
|
+
"@craftzdog/react-native-buffer": "6.0.5",
|
|
72
|
+
"events": "3.3.0",
|
|
73
|
+
"react-native-quick-base64": "2.1.2",
|
|
74
|
+
"readable-stream": "4.5.2",
|
|
75
|
+
"string_decoder": "1.3.0",
|
|
76
|
+
"util": "0.12.5"
|
|
74
77
|
},
|
|
75
78
|
"devDependencies": {
|
|
76
79
|
"@eslint/compat": "^1.1.1",
|
|
77
|
-
"@eslint/js": "9.
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@
|
|
81
|
-
"@
|
|
82
|
-
"@types/
|
|
83
|
-
"
|
|
84
|
-
"
|
|
85
|
-
"
|
|
86
|
-
"
|
|
87
|
-
"
|
|
88
|
-
"eslint-plugin-react-native": "^4.1.0",
|
|
89
|
-
"jest": "^29.7.0",
|
|
80
|
+
"@eslint/js": "9.18.0",
|
|
81
|
+
"@release-it/bumper": "7.0.1",
|
|
82
|
+
"@types/jest": "29.5.11",
|
|
83
|
+
"@types/node": "22.0.0",
|
|
84
|
+
"@types/react": "18.3.3",
|
|
85
|
+
"@types/readable-stream": "4.0.18",
|
|
86
|
+
"del-cli": "6.0.0",
|
|
87
|
+
"eslint": "9.9.0",
|
|
88
|
+
"eslint-plugin-react-native": "5.0.0",
|
|
89
|
+
"jest": "29.7.0",
|
|
90
|
+
"nitro-codegen": "0.21.0",
|
|
90
91
|
"prettier": "3.3.3",
|
|
91
|
-
"react": "18.2.0",
|
|
92
|
-
"react-native": "0.72.7",
|
|
93
92
|
"react-native-builder-bob": "0.35.2",
|
|
94
|
-
"
|
|
95
|
-
"
|
|
96
|
-
"typescript": "5.
|
|
97
|
-
"typescript-eslint": "8.
|
|
93
|
+
"react-native-nitro-modules": "0.21.0",
|
|
94
|
+
"release-it": "18.1.1",
|
|
95
|
+
"typescript": "5.1.6",
|
|
96
|
+
"typescript-eslint": "^8.1.0"
|
|
97
|
+
},
|
|
98
|
+
"peerDependencies": {
|
|
99
|
+
"react": "*",
|
|
100
|
+
"react-native": "*",
|
|
101
|
+
"react-native-nitro-modules": "*"
|
|
98
102
|
},
|
|
99
103
|
"release-it": {
|
|
100
104
|
"npm": {
|
|
@@ -111,7 +115,7 @@
|
|
|
111
115
|
"@release-it/bumper": {
|
|
112
116
|
"out": [
|
|
113
117
|
{
|
|
114
|
-
"file": "../../
|
|
118
|
+
"file": "../../example/package.json",
|
|
115
119
|
"path": [
|
|
116
120
|
"version",
|
|
117
121
|
"dependencies.react-native-quick-crypto"
|
|
@@ -130,13 +134,15 @@
|
|
|
130
134
|
[
|
|
131
135
|
"typescript",
|
|
132
136
|
{
|
|
133
|
-
"project": "tsconfig.json"
|
|
137
|
+
"project": "tsconfig.json",
|
|
138
|
+
"tsc": "../../node_modules/.bin/tsc"
|
|
134
139
|
}
|
|
135
140
|
]
|
|
136
141
|
]
|
|
137
142
|
},
|
|
138
|
-
"
|
|
139
|
-
"
|
|
140
|
-
"
|
|
143
|
+
"trustedDependencies": [
|
|
144
|
+
"react-native-quick-crypto",
|
|
145
|
+
"nitro-codegen",
|
|
146
|
+
"react-native-nitro-modules"
|
|
141
147
|
]
|
|
142
148
|
}
|
package/src/ed.ts
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { NitroModules } from 'react-native-nitro-modules';
|
|
2
|
+
import { binaryLikeToArrayBuffer as toAB } from './utils';
|
|
3
|
+
import type { EdKeyPair } from './specs/edKeyPair.nitro';
|
|
4
|
+
import type { BinaryLike, CFRGKeyPairType, KeyPairGenConfig } from './utils';
|
|
5
|
+
|
|
6
|
+
export class Ed {
|
|
7
|
+
type: CFRGKeyPairType;
|
|
8
|
+
config: KeyPairGenConfig;
|
|
9
|
+
native: EdKeyPair;
|
|
10
|
+
|
|
11
|
+
constructor(type: CFRGKeyPairType, config: KeyPairGenConfig) {
|
|
12
|
+
this.type = type;
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.native = NitroModules.createHybridObject<EdKeyPair>('EdKeyPair');
|
|
15
|
+
this.native.setCurve(type);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
async generateKeyPair(): Promise<void> {
|
|
19
|
+
this.native.generateKeyPair(
|
|
20
|
+
this.config.publicFormat || (-1 as number),
|
|
21
|
+
this.config.publicType || (-1 as number),
|
|
22
|
+
this.config.privateFormat || (-1 as number),
|
|
23
|
+
this.config.privateType || (-1 as number),
|
|
24
|
+
this.config.cipher as string,
|
|
25
|
+
this.config.passphrase as ArrayBuffer,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
generateKeyPairSync(): void {
|
|
30
|
+
this.native.generateKeyPairSync(
|
|
31
|
+
this.config.publicFormat || (-1 as number),
|
|
32
|
+
this.config.publicType || (-1 as number),
|
|
33
|
+
this.config.privateFormat || (-1 as number),
|
|
34
|
+
this.config.privateType || (-1 as number),
|
|
35
|
+
this.config.cipher as string,
|
|
36
|
+
this.config.passphrase as ArrayBuffer,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
getPublicKey(): ArrayBuffer {
|
|
41
|
+
return this.native.getPublicKey();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getPrivateKey(): ArrayBuffer {
|
|
45
|
+
return this.native.getPrivateKey();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async sign(message: BinaryLike, key?: BinaryLike): Promise<ArrayBuffer> {
|
|
49
|
+
return key
|
|
50
|
+
? this.native.sign(toAB(message), toAB(key))
|
|
51
|
+
: this.native.sign(toAB(message));
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
signSync(message: BinaryLike, key?: BinaryLike): ArrayBuffer {
|
|
55
|
+
return key
|
|
56
|
+
? this.native.signSync(toAB(message), toAB(key))
|
|
57
|
+
: this.native.signSync(toAB(message));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async verify(
|
|
61
|
+
signature: BinaryLike,
|
|
62
|
+
message: BinaryLike,
|
|
63
|
+
key?: BinaryLike,
|
|
64
|
+
): Promise<boolean> {
|
|
65
|
+
return key
|
|
66
|
+
? this.native.verify(toAB(signature), toAB(message), toAB(key))
|
|
67
|
+
: this.native.verify(toAB(signature), toAB(message));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
verifySync(
|
|
71
|
+
signature: BinaryLike,
|
|
72
|
+
message: BinaryLike,
|
|
73
|
+
key?: BinaryLike,
|
|
74
|
+
): boolean {
|
|
75
|
+
return key
|
|
76
|
+
? this.native.verifySync(toAB(signature), toAB(message), toAB(key))
|
|
77
|
+
: this.native.verifySync(toAB(signature), toAB(message));
|
|
78
|
+
}
|
|
79
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,62 +1,50 @@
|
|
|
1
|
+
// polyfill imports
|
|
1
2
|
import { Buffer } from '@craftzdog/react-native-buffer';
|
|
3
|
+
|
|
4
|
+
// API imports
|
|
5
|
+
import * as keys from './keys';
|
|
6
|
+
import * as ed from './ed';
|
|
2
7
|
import * as pbkdf2 from './pbkdf2';
|
|
3
8
|
import * as random from './random';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
createDecipher,
|
|
8
|
-
createDecipheriv,
|
|
9
|
-
publicEncrypt,
|
|
10
|
-
publicDecrypt,
|
|
11
|
-
privateDecrypt,
|
|
12
|
-
generateKeyPair,
|
|
13
|
-
generateKeyPairSync,
|
|
14
|
-
} from './Cipher';
|
|
15
|
-
import { generateKey, generateKeySync } from './keygen';
|
|
16
|
-
import { createSign, createVerify } from './sig';
|
|
17
|
-
import { createHmac } from './Hmac';
|
|
18
|
-
import { createHash } from './Hash';
|
|
19
|
-
import { constants } from './constants';
|
|
20
|
-
import { subtle } from './subtle';
|
|
21
|
-
import { getCiphers, getHashes } from './Utils';
|
|
22
|
-
import webcrypto from './webcrypto';
|
|
23
|
-
import { createPrivateKey, createPublicKey, createSecretKey } from './keys';
|
|
9
|
+
|
|
10
|
+
// utils import
|
|
11
|
+
import * as utils from './utils';
|
|
24
12
|
|
|
25
13
|
/**
|
|
26
|
-
* Loosely matches Node.js {crypto} with some unimplemented functionality
|
|
14
|
+
* Loosely matches Node.js {crypto} with some unimplemented functionality.
|
|
15
|
+
* See `docs/implementation-coverage.md` for status.
|
|
27
16
|
*/
|
|
28
17
|
const QuickCrypto = {
|
|
29
|
-
createHmac,
|
|
30
|
-
Hmac: createHmac,
|
|
31
|
-
Hash: createHash,
|
|
32
|
-
createHash,
|
|
33
|
-
createCipher,
|
|
34
|
-
createCipheriv,
|
|
35
|
-
createDecipher,
|
|
36
|
-
createDecipheriv,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
createVerify,
|
|
49
|
-
subtle,
|
|
50
|
-
constants,
|
|
18
|
+
// createHmac,
|
|
19
|
+
// Hmac: createHmac,
|
|
20
|
+
// Hash: createHash,
|
|
21
|
+
// createHash,
|
|
22
|
+
// createCipher,
|
|
23
|
+
// createCipheriv,
|
|
24
|
+
// createDecipher,
|
|
25
|
+
// createDecipheriv,
|
|
26
|
+
// publicEncrypt,
|
|
27
|
+
// publicDecrypt,
|
|
28
|
+
// privateDecrypt,
|
|
29
|
+
// generateKey,
|
|
30
|
+
// generateKeySync,
|
|
31
|
+
// createSign,
|
|
32
|
+
// createVerify,
|
|
33
|
+
// subtle,
|
|
34
|
+
// constants,
|
|
35
|
+
...keys,
|
|
36
|
+
...ed,
|
|
51
37
|
...pbkdf2,
|
|
52
38
|
...random,
|
|
53
|
-
getCiphers,
|
|
54
|
-
getHashes,
|
|
55
|
-
webcrypto,
|
|
39
|
+
// getCiphers,
|
|
40
|
+
// getHashes,
|
|
41
|
+
// webcrypto,
|
|
42
|
+
...utils,
|
|
56
43
|
};
|
|
57
44
|
|
|
58
45
|
/**
|
|
59
|
-
* Optional. Patch global.crypto with
|
|
46
|
+
* Optional. Patch global.crypto with react-native-quick-crypto and
|
|
47
|
+
* global.Buffer with react-native-buffer.
|
|
60
48
|
*/
|
|
61
49
|
export const install = () => {
|
|
62
50
|
// @ts-expect-error copyBytesFrom and poolSizets are missing from react-native-buffer
|
|
@@ -66,7 +54,15 @@ export const install = () => {
|
|
|
66
54
|
global.crypto = QuickCrypto;
|
|
67
55
|
};
|
|
68
56
|
|
|
57
|
+
// random, cipher, hash use nextTick
|
|
58
|
+
global.process.nextTick = setImmediate;
|
|
59
|
+
|
|
60
|
+
// exports
|
|
69
61
|
export default QuickCrypto;
|
|
62
|
+
export * from './ed';
|
|
63
|
+
export * from './pbkdf2';
|
|
64
|
+
export * from './random';
|
|
65
|
+
export * from './utils';
|
|
70
66
|
|
|
71
67
|
// Additional exports for CommonJS compatibility
|
|
72
68
|
module.exports = QuickCrypto;
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import type { KeyObjectHandle } from '../specs/keyObjectHandle.nitro';
|
|
2
|
+
import type {
|
|
3
|
+
AsymmetricKeyType,
|
|
4
|
+
EncodingOptions,
|
|
5
|
+
KeyUsage,
|
|
6
|
+
SubtleAlgorithm,
|
|
7
|
+
} from '../utils';
|
|
8
|
+
import { parsePrivateKeyEncoding, parsePublicKeyEncoding } from './utils';
|
|
9
|
+
|
|
10
|
+
export class CryptoKey {
|
|
11
|
+
keyObject: KeyObject;
|
|
12
|
+
keyAlgorithm: SubtleAlgorithm;
|
|
13
|
+
keyUsages: KeyUsage[];
|
|
14
|
+
keyExtractable: boolean;
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
keyObject: KeyObject,
|
|
18
|
+
keyAlgorithm: SubtleAlgorithm,
|
|
19
|
+
keyUsages: KeyUsage[],
|
|
20
|
+
keyExtractable: boolean,
|
|
21
|
+
) {
|
|
22
|
+
this.keyObject = keyObject;
|
|
23
|
+
this.keyAlgorithm = keyAlgorithm;
|
|
24
|
+
this.keyUsages = keyUsages;
|
|
25
|
+
this.keyExtractable = keyExtractable;
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
28
|
+
inspect(_depth: number, _options: unknown): unknown {
|
|
29
|
+
throw new Error('CryptoKey.inspect is not implemented');
|
|
30
|
+
// if (depth < 0) return this;
|
|
31
|
+
|
|
32
|
+
// const opts = {
|
|
33
|
+
// ...options,
|
|
34
|
+
// depth: options.depth == null ? null : options.depth - 1,
|
|
35
|
+
// };
|
|
36
|
+
|
|
37
|
+
// return `CryptoKey ${inspect(
|
|
38
|
+
// {
|
|
39
|
+
// type: this.type,
|
|
40
|
+
// extractable: this.extractable,
|
|
41
|
+
// algorithm: this.algorithm,
|
|
42
|
+
// usages: this.usages,
|
|
43
|
+
// },
|
|
44
|
+
// opts
|
|
45
|
+
// )}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
get type() {
|
|
49
|
+
// if (!(this instanceof CryptoKey)) throw new Error('Invalid CryptoKey');
|
|
50
|
+
return this.keyObject.type;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
get extractable() {
|
|
54
|
+
return this.keyExtractable;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
get algorithm() {
|
|
58
|
+
return this.keyAlgorithm;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
get usages() {
|
|
62
|
+
return this.keyUsages;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export class KeyObject {
|
|
67
|
+
handle: KeyObjectHandle;
|
|
68
|
+
type: 'public' | 'secret' | 'private' | 'unknown' = 'unknown';
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
70
|
+
export(_options?: EncodingOptions): ArrayBuffer {
|
|
71
|
+
return new ArrayBuffer(0);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
constructor(type: string, handle: KeyObjectHandle) {
|
|
75
|
+
if (type !== 'secret' && type !== 'public' && type !== 'private')
|
|
76
|
+
throw new Error(`invalid KeyObject type: ${type}`);
|
|
77
|
+
this.handle = handle;
|
|
78
|
+
this.type = type;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// get type(): string {
|
|
82
|
+
// return this.type;
|
|
83
|
+
// }
|
|
84
|
+
|
|
85
|
+
// static from(key) {
|
|
86
|
+
// if (!isCryptoKey(key))
|
|
87
|
+
// throw new ERR_INVALID_ARG_TYPE('key', 'CryptoKey', key);
|
|
88
|
+
// return key[kKeyObject];
|
|
89
|
+
// }
|
|
90
|
+
|
|
91
|
+
// equals(otherKeyObject) {
|
|
92
|
+
// if (!isKeyObject(otherKeyObject)) {
|
|
93
|
+
// throw new ERR_INVALID_ARG_TYPE(
|
|
94
|
+
// 'otherKeyObject',
|
|
95
|
+
// 'KeyObject',
|
|
96
|
+
// otherKeyObject
|
|
97
|
+
// );
|
|
98
|
+
// }
|
|
99
|
+
|
|
100
|
+
// return (
|
|
101
|
+
// otherKeyObject.type === this.type &&
|
|
102
|
+
// this[kHandle].equals(otherKeyObject[kHandle])
|
|
103
|
+
// );
|
|
104
|
+
// }
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export class SecretKeyObject extends KeyObject {
|
|
108
|
+
constructor(handle: KeyObjectHandle) {
|
|
109
|
+
super('secret', handle);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// get symmetricKeySize() {
|
|
113
|
+
// return this[kHandle].getSymmetricKeySize();
|
|
114
|
+
// }
|
|
115
|
+
|
|
116
|
+
export(options?: EncodingOptions) {
|
|
117
|
+
if (options !== undefined) {
|
|
118
|
+
if (options.format === 'jwk') {
|
|
119
|
+
throw new Error('SecretKey export for jwk is not implemented');
|
|
120
|
+
// return this.handle.exportJwk({}, false);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return this.handle.exportKey();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// const kAsymmetricKeyType = Symbol('kAsymmetricKeyType');
|
|
128
|
+
// const kAsymmetricKeyDetails = Symbol('kAsymmetricKeyDetails');
|
|
129
|
+
|
|
130
|
+
// function normalizeKeyDetails(details = {}) {
|
|
131
|
+
// if (details.publicExponent !== undefined) {
|
|
132
|
+
// return {
|
|
133
|
+
// ...details,
|
|
134
|
+
// publicExponent: bigIntArrayToUnsignedBigInt(
|
|
135
|
+
// new Uint8Array(details.publicExponent)
|
|
136
|
+
// ),
|
|
137
|
+
// };
|
|
138
|
+
// }
|
|
139
|
+
// return details;
|
|
140
|
+
// }
|
|
141
|
+
|
|
142
|
+
export class AsymmetricKeyObject extends KeyObject {
|
|
143
|
+
constructor(type: string, handle: KeyObjectHandle) {
|
|
144
|
+
super(type, handle);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
private _asymmetricKeyType?: AsymmetricKeyType;
|
|
148
|
+
|
|
149
|
+
get asymmetricKeyType(): AsymmetricKeyType {
|
|
150
|
+
if (!this._asymmetricKeyType) {
|
|
151
|
+
this._asymmetricKeyType = this.handle.getAsymmetricKeyType();
|
|
152
|
+
}
|
|
153
|
+
return this._asymmetricKeyType;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// get asymmetricKeyDetails() {
|
|
157
|
+
// switch (this._asymmetricKeyType) {
|
|
158
|
+
// case 'rsa':
|
|
159
|
+
// case 'rsa-pss':
|
|
160
|
+
// case 'dsa':
|
|
161
|
+
// case 'ec':
|
|
162
|
+
// return (
|
|
163
|
+
// this[kAsymmetricKeyDetails] ||
|
|
164
|
+
// (this[kAsymmetricKeyDetails] = normalizeKeyDetails(
|
|
165
|
+
// this[kHandle].keyDetail({})
|
|
166
|
+
// ))
|
|
167
|
+
// );
|
|
168
|
+
// default:
|
|
169
|
+
// return {};
|
|
170
|
+
// }
|
|
171
|
+
// }
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export class PublicKeyObject extends AsymmetricKeyObject {
|
|
175
|
+
constructor(handle: KeyObjectHandle) {
|
|
176
|
+
super('public', handle);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export(options: EncodingOptions) {
|
|
180
|
+
if (options?.format === 'jwk') {
|
|
181
|
+
throw new Error('PublicKey export for jwk is not implemented');
|
|
182
|
+
// return this.handle.exportJwk({}, false);
|
|
183
|
+
}
|
|
184
|
+
const { format, type } = parsePublicKeyEncoding(
|
|
185
|
+
options,
|
|
186
|
+
this.asymmetricKeyType,
|
|
187
|
+
);
|
|
188
|
+
return this.handle.exportKey(format, type);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export class PrivateKeyObject extends AsymmetricKeyObject {
|
|
193
|
+
constructor(handle: KeyObjectHandle) {
|
|
194
|
+
super('private', handle);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export(options: EncodingOptions) {
|
|
198
|
+
if (options?.format === 'jwk') {
|
|
199
|
+
if (options.passphrase !== undefined) {
|
|
200
|
+
throw new Error('jwk does not support encryption');
|
|
201
|
+
}
|
|
202
|
+
throw new Error('PrivateKey export for jwk is not implemented');
|
|
203
|
+
// return this.handle.exportJwk({}, false);
|
|
204
|
+
}
|
|
205
|
+
const { format, type, cipher, passphrase } = parsePrivateKeyEncoding(
|
|
206
|
+
options,
|
|
207
|
+
this.asymmetricKeyType,
|
|
208
|
+
);
|
|
209
|
+
return this.handle.exportKey(format, type, cipher, passphrase);
|
|
210
|
+
}
|
|
211
|
+
}
|