@account-kit/react-native-signer 4.7.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account-kit-react-native-signer.podspec +18 -18
- package/android/src/main/java/com/accountkit/reactnativesigner/core/TEKStamper.kt +84 -25
- package/ios/NativeTEKStamper.h +10 -0
- package/ios/NativeTEKStamper.mm +70 -0
- package/ios/implementation/NativeTEKStamperImpl.swift +95 -0
- package/ios/turnkey/AuthManager.swift +85 -0
- package/ios/turnkey/Data+EncodingExtensions.swift +88 -0
- package/ios/turnkey/P256+String.swift +97 -0
- package/ios/turnkey/String+Hex.swift +24 -0
- package/lib/commonjs/client.js +18 -7
- package/lib/commonjs/client.js.map +1 -1
- package/lib/commonjs/signer.js +15 -3
- package/lib/commonjs/signer.js.map +1 -1
- package/lib/module/client.js +18 -7
- package/lib/module/client.js.map +1 -1
- package/lib/module/signer.js +14 -1
- package/lib/module/signer.js.map +1 -1
- package/lib/typescript/commonjs/src/client.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/signer.d.ts +1 -3
- package/lib/typescript/commonjs/src/signer.d.ts.map +1 -1
- package/lib/typescript/module/src/client.d.ts.map +1 -1
- package/lib/typescript/module/src/signer.d.ts +1 -3
- package/lib/typescript/module/src/signer.d.ts.map +1 -1
- package/package.json +8 -7
- package/src/client.ts +19 -7
- package/src/signer.ts +21 -2
- package/ios/ReactNativeSigner.h +0 -12
- package/ios/ReactNativeSigner.mm +0 -21
|
@@ -11,10 +11,14 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios =>
|
|
15
|
-
s.source = { :git => "https://github.com/
|
|
14
|
+
s.platforms = { :ios => "17.0" }
|
|
15
|
+
s.source = { :git => "https://github.com/alchemyplatform/aa-sdk.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
|
-
s.source_files = "ios/**/*.{h,m,mm,cpp}"
|
|
17
|
+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
|
|
18
|
+
s.private_header_files = "ios/**/*.h"
|
|
19
|
+
|
|
20
|
+
# spm_dependency(s, url: "https://github.com/tkhq/swift-sdk", requirement: {kind: 'upToNextMajorVersion', minimumVersion: '1.2.0'}, products: ["TurnkeySDK"])
|
|
21
|
+
s.dependency "Base58Swift"
|
|
18
22
|
|
|
19
23
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
20
24
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -22,20 +26,16 @@ Pod::Spec.new do |s|
|
|
|
22
26
|
install_modules_dependencies(s)
|
|
23
27
|
else
|
|
24
28
|
s.dependency "React-Core"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
s.dependency "RCTRequired"
|
|
37
|
-
s.dependency "RCTTypeSafety"
|
|
38
|
-
s.dependency "ReactCommon/turbomodule/core"
|
|
39
|
-
end
|
|
29
|
+
s.compiler_flags = folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED=1"
|
|
30
|
+
s.pod_target_xcconfig = {
|
|
31
|
+
"HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\"",
|
|
32
|
+
"OTHER_CPLUSPLUSFLAGS" => "-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1",
|
|
33
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++17"
|
|
34
|
+
}
|
|
35
|
+
s.dependency "React-Codegen"
|
|
36
|
+
s.dependency "RCT-Folly"
|
|
37
|
+
s.dependency "RCTRequired"
|
|
38
|
+
s.dependency "RCTTypeSafety"
|
|
39
|
+
s.dependency "ReactCommon/turbomodule/core"
|
|
40
40
|
end
|
|
41
41
|
end
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
package com.accountkit.reactnativesigner.core
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import android.content.SharedPreferences
|
|
4
5
|
import androidx.security.crypto.EncryptedSharedPreferences
|
|
5
6
|
import androidx.security.crypto.MasterKey
|
|
6
7
|
import com.accountkit.reactnativesigner.core.errors.NoInjectedBundleException
|
|
@@ -19,6 +20,8 @@ import java.nio.ByteBuffer
|
|
|
19
20
|
import java.security.KeyFactory
|
|
20
21
|
import java.security.Security
|
|
21
22
|
import java.security.Signature
|
|
23
|
+
import java.security.KeyStore
|
|
24
|
+
import java.security.KeyStoreException
|
|
22
25
|
|
|
23
26
|
@Serializable
|
|
24
27
|
data class ApiStamp(val publicKey: String, val scheme: String, val signature: String)
|
|
@@ -27,6 +30,8 @@ data class Stamp(val stampHeaderName: String, val stampHeaderValue: String)
|
|
|
27
30
|
|
|
28
31
|
private const val BUNDLE_PRIVATE_KEY = "BUNDLE_PRIVATE_KEY"
|
|
29
32
|
private const val BUNDLE_PUBLIC_KEY = "BUNDLE_PUBLIC_KEY"
|
|
33
|
+
private const val MASTER_KEY_ALIAS = "tek_master_key"
|
|
34
|
+
private const val ENCRYPTED_SHARED_PREFERENCES_FILENAME = "tek_stamper_shared_prefs"
|
|
30
35
|
|
|
31
36
|
class TEKStamper(context: Context) {
|
|
32
37
|
// This is how the docs for EncryptedSharedPreferences recommend creating this setup
|
|
@@ -36,12 +41,6 @@ class TEKStamper(context: Context) {
|
|
|
36
41
|
//
|
|
37
42
|
// we should explore the best practices on how to do this once we reach a phase of further
|
|
38
43
|
// cleanup
|
|
39
|
-
private val masterKey =
|
|
40
|
-
MasterKey.Builder(context.applicationContext)
|
|
41
|
-
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
42
|
-
// requires that the phone be unlocked
|
|
43
|
-
.setUserAuthenticationRequired(false)
|
|
44
|
-
.build()
|
|
45
44
|
|
|
46
45
|
/**
|
|
47
46
|
* We are using EncryptedSharedPreferences to store 2 pieces of data
|
|
@@ -64,29 +63,35 @@ class TEKStamper(context: Context) {
|
|
|
64
63
|
*
|
|
65
64
|
* The open question is if the storage of the decrypted private key is secure enough though
|
|
66
65
|
*/
|
|
67
|
-
|
|
68
|
-
EncryptedSharedPreferences.create(
|
|
69
|
-
context,
|
|
70
|
-
"tek_stamper_shared_prefs",
|
|
71
|
-
masterKey,
|
|
72
|
-
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
73
|
-
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
74
|
-
)
|
|
66
|
+
|
|
75
67
|
|
|
76
|
-
private val tekManager = HpkeTEKManager(sharedPreferences)
|
|
77
68
|
|
|
78
|
-
|
|
79
|
-
|
|
69
|
+
|
|
70
|
+
|
|
80
71
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
72
|
+
private lateinit var tekManager: HpkeTEKManager
|
|
73
|
+
private lateinit var sharedPreferences: SharedPreferences
|
|
74
|
+
|
|
75
|
+
init {
|
|
76
|
+
try {
|
|
77
|
+
TinkConfig.register()
|
|
78
|
+
|
|
79
|
+
sharedPreferences = getSharedPreferences(context)
|
|
80
|
+
tekManager = HpkeTEKManager(sharedPreferences)
|
|
81
|
+
|
|
82
|
+
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME).javaClass !=
|
|
83
|
+
BouncyCastleProvider::class.java
|
|
84
|
+
) {
|
|
85
|
+
Security.removeProvider(BouncyCastleProvider.PROVIDER_NAME)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (Security.getProvider(BouncyCastleProvider.PROVIDER_NAME) == null) {
|
|
89
|
+
Security.addProvider(BouncyCastleProvider())
|
|
90
|
+
}
|
|
91
|
+
} catch (e: Exception){
|
|
92
|
+
throw RuntimeException("Error creating master key", e)
|
|
89
93
|
}
|
|
94
|
+
|
|
90
95
|
}
|
|
91
96
|
|
|
92
97
|
fun init(): String {
|
|
@@ -196,4 +201,58 @@ class TEKStamper(context: Context) {
|
|
|
196
201
|
)
|
|
197
202
|
return Pair(compressedPublicKey, privateKey)
|
|
198
203
|
}
|
|
204
|
+
|
|
205
|
+
private fun createSharedPreferences(masterKey: MasterKey, context: Context): SharedPreferences {
|
|
206
|
+
return EncryptedSharedPreferences.create(
|
|
207
|
+
context,
|
|
208
|
+
ENCRYPTED_SHARED_PREFERENCES_FILENAME,
|
|
209
|
+
masterKey,
|
|
210
|
+
EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV,
|
|
211
|
+
EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM
|
|
212
|
+
)
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
private fun createMasterKey(context: Context): MasterKey {
|
|
216
|
+
return MasterKey.Builder(context.applicationContext, MASTER_KEY_ALIAS)
|
|
217
|
+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
|
|
218
|
+
.setUserAuthenticationRequired(false)
|
|
219
|
+
.build()
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
private fun getSharedPreferences(context: Context): SharedPreferences {
|
|
224
|
+
try {
|
|
225
|
+
// Attempt to create or load the EncryptedSharedPreferences file
|
|
226
|
+
val masterKey = createMasterKey(context)
|
|
227
|
+
|
|
228
|
+
return createSharedPreferences(masterKey, context)
|
|
229
|
+
} catch(e: Exception) {
|
|
230
|
+
// Log the Exception
|
|
231
|
+
e.printStackTrace()
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// An error occured creating or retrieving the Shared Preferences file.
|
|
235
|
+
// Delete the existing master key and EncryptedSharedPreferences
|
|
236
|
+
|
|
237
|
+
// first delete the MasterKey
|
|
238
|
+
try {
|
|
239
|
+
val keyStore = KeyStore.getInstance("AndroidKeyStore")
|
|
240
|
+
keyStore.load(null)
|
|
241
|
+
keyStore.deleteEntry(MASTER_KEY_ALIAS)
|
|
242
|
+
} catch (keyStoreDeletionException: Exception) {
|
|
243
|
+
throw RuntimeException("An error occured deleting the Master Key", keyStoreDeletionException)
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// attempt to recreate a new EncryptedSharedPreferences file
|
|
247
|
+
try {
|
|
248
|
+
// Create a new MasterKey
|
|
249
|
+
val newMasterKey = createMasterKey(context)
|
|
250
|
+
context.getSharedPreferences(ENCRYPTED_SHARED_PREFERENCES_FILENAME, Context.MODE_PRIVATE).edit().clear().apply()
|
|
251
|
+
context.deleteSharedPreferences(ENCRYPTED_SHARED_PREFERENCES_FILENAME)
|
|
252
|
+
|
|
253
|
+
return createSharedPreferences(newMasterKey, context)
|
|
254
|
+
} catch(retryException: Exception) {
|
|
255
|
+
throw RuntimeException("Couldn't create the required shared preferences file. Ensure you are properly authenticated on this device.", retryException)
|
|
256
|
+
}
|
|
257
|
+
}
|
|
199
258
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
2
|
+
#import "NativeTEKStamper.h"
|
|
3
|
+
#if __has_include("account_kit_react_native_signer/account_kit_react_native_signer-Swift.h")
|
|
4
|
+
#import "account_kit_react_native_signer/account_kit_react_native_signer-Swift.h"
|
|
5
|
+
#else
|
|
6
|
+
#import "account_kit_react_native_signer-Swift.h"
|
|
7
|
+
#endif
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
@implementation NativeTEKStamper {
|
|
11
|
+
NativeTEKStamperImpl *_stamper;
|
|
12
|
+
}
|
|
13
|
+
RCT_EXPORT_MODULE()
|
|
14
|
+
|
|
15
|
+
- (id) init {
|
|
16
|
+
self = [super init];
|
|
17
|
+
if (self) {
|
|
18
|
+
_stamper = [NativeTEKStamperImpl new];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return self;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
- (void)clear {
|
|
25
|
+
[_stamper clear];
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
- (void)init:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
29
|
+
[_stamper createWithCompletionHandler:^(NSString * _Nullable result, NSError * _Nullable error) {
|
|
30
|
+
if (error) {
|
|
31
|
+
return reject([NSString stringWithFormat: @"%ld", (long)error.code], error.description, error);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return resolve(result);
|
|
35
|
+
}];
|
|
36
|
+
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)injectCredentialBundle:(NSString *)bundle resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
40
|
+
[_stamper injectCredentialBundleWithBundle:bundle completionHandler:^(BOOL success, NSError * _Nullable error) {
|
|
41
|
+
if (error) {
|
|
42
|
+
return reject([NSString stringWithFormat: @"%ld", (long)error.code], error.description, error);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return resolve(@(success));
|
|
46
|
+
}];
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (NSString * _Nullable)publicKey {
|
|
50
|
+
return [_stamper publicKey];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
- (void)stamp:(NSString *)payload resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
54
|
+
[_stamper stampWithPayload:payload completionHandler:^(NSDictionary<NSString *,id> * _Nullable result, NSError * _Nullable error) {
|
|
55
|
+
if (error) {
|
|
56
|
+
return reject([NSString stringWithFormat: @"%ld", (long)error.code], error.description, error);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return resolve(result);
|
|
60
|
+
}];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
64
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
65
|
+
{
|
|
66
|
+
return std::make_shared<facebook::react::NativeTEKStamperSpecJSI>(params);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@end
|
|
70
|
+
#endif // RCT_NEW_ARCH_ENABLED
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import CryptoKit
|
|
2
|
+
import Foundation
|
|
3
|
+
|
|
4
|
+
enum StamperError: Error {
|
|
5
|
+
case notInitialized
|
|
6
|
+
case invalidPayload
|
|
7
|
+
case signatureFailed
|
|
8
|
+
case failedToSerializePayloadToJSON(Error)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
@objc public class NativeTEKStamperImpl: NSObject {
|
|
12
|
+
// TODO: we probably want to keep this longer term somewhere, because the RN session manager will
|
|
13
|
+
// hold on to the bundle and try to recreate a session if a user is still logged in
|
|
14
|
+
var ephemeralPrivateKey: P256.KeyAgreement.PrivateKey? = nil;
|
|
15
|
+
|
|
16
|
+
// These can be ephemeral and held in memory because the session manager will handle re-authenticating
|
|
17
|
+
var apiPublicKey: P256.Signing.PublicKey? = nil;
|
|
18
|
+
var apiPrivateKey: P256.Signing.PrivateKey? = nil;
|
|
19
|
+
|
|
20
|
+
@objc public func create() async throws -> NSString {
|
|
21
|
+
if (ephemeralPrivateKey == nil) {
|
|
22
|
+
ephemeralPrivateKey = P256.KeyAgreement.PrivateKey()
|
|
23
|
+
}
|
|
24
|
+
let targetPublicKey = try ephemeralPrivateKey!.publicKey.toString(representation: .x963)
|
|
25
|
+
|
|
26
|
+
return NSString(string: targetPublicKey)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@objc public func clear() {
|
|
30
|
+
ephemeralPrivateKey = nil
|
|
31
|
+
apiPublicKey = nil
|
|
32
|
+
apiPrivateKey = nil
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@objc public func publicKey() -> NSString? {
|
|
36
|
+
if let ephemeralPrivateKey = ephemeralPrivateKey {
|
|
37
|
+
let publicKey = try? ephemeralPrivateKey.publicKey.toString(representation: .x963)
|
|
38
|
+
return publicKey != nil ? NSString(string: publicKey!) : nil
|
|
39
|
+
} else {
|
|
40
|
+
return nil;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@objc public func injectCredentialBundle(bundle: NSString) async throws -> ObjCBool {
|
|
45
|
+
if let ephemeralPrivateKey = ephemeralPrivateKey {
|
|
46
|
+
let (bundlePrivateKey, bundlePublicKey) = try AuthManager.decryptBundle(encryptedBundle: bundle as String, ephemeralPrivateKey: ephemeralPrivateKey)
|
|
47
|
+
|
|
48
|
+
apiPublicKey = bundlePublicKey
|
|
49
|
+
apiPrivateKey = bundlePrivateKey
|
|
50
|
+
|
|
51
|
+
return true;
|
|
52
|
+
} else {
|
|
53
|
+
throw StamperError.notInitialized
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// TODO: we should use the turnkey stamper for all of this, but we need it published as a pod
|
|
58
|
+
// and it shouldn't require use_frameworks!
|
|
59
|
+
@objc public func stamp(payload: NSString) async throws -> [String: NSString] {
|
|
60
|
+
if let apiPublicKey = apiPublicKey, let apiPrivateKey = apiPrivateKey {
|
|
61
|
+
guard let payloadData = String(payload).data(using: .utf8) else {
|
|
62
|
+
throw StamperError.invalidPayload
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let payloadHash = SHA256.hash(data: payloadData)
|
|
66
|
+
|
|
67
|
+
guard let signature = try? apiPrivateKey.signature(for: payloadHash) else {
|
|
68
|
+
throw StamperError.signatureFailed
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
let signatureHex = signature.derRepresentation.toHexString()
|
|
72
|
+
|
|
73
|
+
print(apiPublicKey.compressedRepresentation.toHexString())
|
|
74
|
+
let stamp: [String: Any] = [
|
|
75
|
+
"publicKey": apiPublicKey.compressedRepresentation.toHexString(),
|
|
76
|
+
"scheme": "SIGNATURE_SCHEME_TK_API_P256",
|
|
77
|
+
"signature": signatureHex,
|
|
78
|
+
]
|
|
79
|
+
|
|
80
|
+
do {
|
|
81
|
+
let jsonData = try JSONSerialization.data(withJSONObject: stamp, options: [])
|
|
82
|
+
let base64Stamp = jsonData.base64URLEncodedString()
|
|
83
|
+
|
|
84
|
+
return [
|
|
85
|
+
"stampHeaderName": NSString(string: "X-Stamp"),
|
|
86
|
+
"stampHeaderValue": NSString(string: base64Stamp),
|
|
87
|
+
]
|
|
88
|
+
} catch {
|
|
89
|
+
throw StamperError.failedToSerializePayloadToJSON(error)
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
throw StamperError.notInitialized
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
//
|
|
2
|
+
// AuthManager.swift
|
|
3
|
+
//
|
|
4
|
+
// This file contains the implementation of the AuthManager, which provides functionalities
|
|
5
|
+
// for decrypting encrypted bundles using elliptic curve cryptography.
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
import Base58Swift
|
|
10
|
+
import CryptoKit
|
|
11
|
+
import Foundation
|
|
12
|
+
|
|
13
|
+
public enum AuthError: Error {
|
|
14
|
+
case invalidCompressedKeyLength
|
|
15
|
+
case keyDecryptionFailed(Error)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/// A manager responsible for handling authentication processes, specifically
|
|
19
|
+
/// dealing with cryptographic operations related to key decryption.
|
|
20
|
+
public struct AuthManager {
|
|
21
|
+
|
|
22
|
+
/// Decrypts an encrypted bundle using a given ephemeral private key.
|
|
23
|
+
///
|
|
24
|
+
/// This method decodes the encrypted bundle, extracts and processes the encapsulated key,
|
|
25
|
+
/// and then decrypts the private key using HPKE (Hybrid Public Key Encryption).
|
|
26
|
+
///
|
|
27
|
+
/// - Parameters:
|
|
28
|
+
/// - encryptedBundle: The encrypted data as a Base58Check encoded string received by the user via their provided email address during the email authentication process.
|
|
29
|
+
/// - ephemeralPrivateKey: The ephemeral private key used for decryption, conforming to `P256.KeyAgreement.PrivateKey`.
|
|
30
|
+
/// - Returns: A tuple containing the decrypted `P256.Signing.PrivateKey` and its corresponding `P256.Signing.PublicKey`.
|
|
31
|
+
/// - Throws: `AuthError.invalidCompressedKeyLength` if the encapsulated key length is incorrect,
|
|
32
|
+
/// `AuthError.keyDecryptionFailed` if any step in the decryption process fails.
|
|
33
|
+
public static func decryptBundle(
|
|
34
|
+
encryptedBundle: String, ephemeralPrivateKey: P256.KeyAgreement.PrivateKey
|
|
35
|
+
) throws
|
|
36
|
+
-> (P256.Signing.PrivateKey, P256.Signing.PublicKey)
|
|
37
|
+
{
|
|
38
|
+
// let base58Check = Base58Check()
|
|
39
|
+
do {
|
|
40
|
+
// Decode the encrypted bundle from Base58Check format.
|
|
41
|
+
// TODO: need to throw here in case this returns null
|
|
42
|
+
let decodedEncryptedBundle = Base58.base58CheckDecode(encryptedBundle)!
|
|
43
|
+
|
|
44
|
+
// Extract the first 33 bytes as the compressed encapsulated key.
|
|
45
|
+
let compressedEncapsulatedKey = decodedEncryptedBundle.prefix(33)
|
|
46
|
+
// The remainder is the encrypted private key.
|
|
47
|
+
let encryptedPrivateKey = decodedEncryptedBundle.dropFirst(33)
|
|
48
|
+
|
|
49
|
+
guard compressedEncapsulatedKey.count == 33 else {
|
|
50
|
+
throw AuthError.invalidCompressedKeyLength
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
let uncompressedEncapsulatedKey = try P256.KeyAgreement.PublicKey(
|
|
54
|
+
compressedRepresentation: compressedEncapsulatedKey
|
|
55
|
+
).x963Representation
|
|
56
|
+
|
|
57
|
+
let receiverPublicKey = ephemeralPrivateKey.publicKey.x963Representation
|
|
58
|
+
|
|
59
|
+
let ciphersuite = HPKE.Ciphersuite(
|
|
60
|
+
kem: HPKE.KEM.P256_HKDF_SHA256, kdf: HPKE.KDF.HKDF_SHA256, aead: HPKE.AEAD.AES_GCM_256)
|
|
61
|
+
|
|
62
|
+
var recipient = try HPKE.Recipient(
|
|
63
|
+
privateKey: ephemeralPrivateKey,
|
|
64
|
+
ciphersuite: ciphersuite,
|
|
65
|
+
info: "turnkey_hpke".data(using: .utf8)!,
|
|
66
|
+
encapsulatedKey: uncompressedEncapsulatedKey
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
// Add the additional authenticated data for the decryption process.
|
|
70
|
+
let aad = uncompressedEncapsulatedKey + receiverPublicKey
|
|
71
|
+
|
|
72
|
+
// Decrypt the private key using the recipient object.
|
|
73
|
+
let compressedPrivateKey = try recipient.open(encryptedPrivateKey, authenticating: aad)
|
|
74
|
+
|
|
75
|
+
// Create the signing private key from its raw representation.
|
|
76
|
+
let privateKey = try P256.Signing.PrivateKey(rawRepresentation: compressedPrivateKey)
|
|
77
|
+
|
|
78
|
+
let publicKey = privateKey.publicKey
|
|
79
|
+
|
|
80
|
+
return (privateKey: privateKey, publicKey: publicKey)
|
|
81
|
+
} catch {
|
|
82
|
+
throw AuthError.keyDecryptionFailed(error)
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Data+EncodingExtensions.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import CryptoKit
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
extension Data {
|
|
11
|
+
public init?(hexString: String) {
|
|
12
|
+
let len = hexString.count / 2
|
|
13
|
+
var data = Data(capacity: len)
|
|
14
|
+
for i in 0..<len {
|
|
15
|
+
let j = hexString.index(hexString.startIndex, offsetBy: i * 2)
|
|
16
|
+
let k = hexString.index(j, offsetBy: 2)
|
|
17
|
+
let bytes = hexString[j..<k]
|
|
18
|
+
if var num = UInt8(bytes, radix: 16) {
|
|
19
|
+
data.append(&num, count: 1)
|
|
20
|
+
} else {
|
|
21
|
+
return nil
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
self = data
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public func toHexString() -> String {
|
|
28
|
+
return map { String(format: "%02x", $0) }.joined()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public func base64URLEncodedString() -> String {
|
|
32
|
+
let base64String = self.base64EncodedString()
|
|
33
|
+
let base64URLString =
|
|
34
|
+
base64String
|
|
35
|
+
.replacingOccurrences(of: "+", with: "-")
|
|
36
|
+
.replacingOccurrences(of: "/", with: "_")
|
|
37
|
+
.trimmingCharacters(in: CharacterSet(charactersIn: "="))
|
|
38
|
+
return base64URLString
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/// Initializes `Data` by decoding a base64 URL encoded string.
|
|
42
|
+
/// - Parameter base64URLEncoded: The base64 URL encoded string.
|
|
43
|
+
/// - Returns: An optional `Data` instance if the string is valid and successfully decoded, otherwise `nil`.
|
|
44
|
+
public init?(base64URLEncoded: String) {
|
|
45
|
+
let paddedBase64 =
|
|
46
|
+
base64URLEncoded
|
|
47
|
+
.replacingOccurrences(of: "-", with: "+")
|
|
48
|
+
.replacingOccurrences(of: "_", with: "/")
|
|
49
|
+
// Adjust the string to ensure it's a multiple of 4 for valid base64 decoding
|
|
50
|
+
let paddingLength = (4 - paddedBase64.count % 4) % 4
|
|
51
|
+
let paddedBase64String = paddedBase64 + String(repeating: "=", count: paddingLength)
|
|
52
|
+
guard let data = Data(base64Encoded: paddedBase64String) else {
|
|
53
|
+
return nil
|
|
54
|
+
}
|
|
55
|
+
self = data
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/// Decodes a hexadecimal string into `Data`.
|
|
59
|
+
/// - Parameter hex: The hexadecimal string to decode.
|
|
60
|
+
/// - Throws: An error if the string contains non-hexadecimal characters or has an odd length.
|
|
61
|
+
/// - Returns: A `Data` object containing the decoded bytes.
|
|
62
|
+
public static func decodeHex(_ hex: String) throws -> Data {
|
|
63
|
+
guard hex.count % 2 == 0 else {
|
|
64
|
+
throw DecodingError.oddLengthString
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
var data = Data()
|
|
68
|
+
var bytePair = ""
|
|
69
|
+
|
|
70
|
+
for char in hex {
|
|
71
|
+
bytePair += String(char)
|
|
72
|
+
if bytePair.count == 2 {
|
|
73
|
+
guard let byte = UInt8(bytePair, radix: 16) else {
|
|
74
|
+
throw DecodingError.invalidHexCharacter
|
|
75
|
+
}
|
|
76
|
+
data.append(byte)
|
|
77
|
+
bytePair = ""
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return data
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
enum DecodingError: Error {
|
|
85
|
+
case oddLengthString
|
|
86
|
+
case invalidHexCharacter
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
//
|
|
2
|
+
// P256+String.swift
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
import CryptoKit
|
|
8
|
+
import Foundation
|
|
9
|
+
|
|
10
|
+
enum KeyError: Error {
|
|
11
|
+
case representationUnavailable(String)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public protocol P256KeyProtocol {
|
|
15
|
+
var rawRepresentation: Data { get }
|
|
16
|
+
var x963Representation: Data { get }
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public protocol P256PublicKeyProtocol: P256KeyProtocol {
|
|
20
|
+
@available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *)
|
|
21
|
+
var compressedRepresentation: Data { get }
|
|
22
|
+
var compactRepresentation: Data? { get }
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
extension P256KeyProtocol {
|
|
26
|
+
/// Converts the key into the specified string representation.
|
|
27
|
+
///
|
|
28
|
+
/// - Parameter representation: The desired representation of the key.
|
|
29
|
+
/// - Returns: A string representation of the key in the specified format.
|
|
30
|
+
/// - Throws: `KeyError.representationUnavailable` if the desired representation is not available.
|
|
31
|
+
public func toString(representation: PrivateKeyRepresentation) throws -> String {
|
|
32
|
+
switch representation {
|
|
33
|
+
case .raw:
|
|
34
|
+
return rawRepresentation.toHexString()
|
|
35
|
+
case .x963:
|
|
36
|
+
return x963Representation.toHexString()
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
extension P256.Signing.PublicKey: P256PublicKeyProtocol {}
|
|
42
|
+
extension P256.KeyAgreement.PublicKey: P256PublicKeyProtocol {}
|
|
43
|
+
|
|
44
|
+
public enum PublicKeyRepresentation {
|
|
45
|
+
case raw
|
|
46
|
+
case x963
|
|
47
|
+
case compressed
|
|
48
|
+
case compact
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
extension P256PublicKeyProtocol {
|
|
52
|
+
/// Converts the public key into the specified string representation.
|
|
53
|
+
///
|
|
54
|
+
/// - Parameter representation: The desired representation of the key.
|
|
55
|
+
/// - Returns: A string representation of the public key in the specified format.
|
|
56
|
+
/// - Throws: `KeyError.representationUnavailable` if the desired representation is not available.
|
|
57
|
+
public func toString(representation: PublicKeyRepresentation) throws -> String {
|
|
58
|
+
switch representation {
|
|
59
|
+
case .raw:
|
|
60
|
+
return rawRepresentation.toHexString()
|
|
61
|
+
case .x963:
|
|
62
|
+
return x963Representation.toHexString()
|
|
63
|
+
case .compressed:
|
|
64
|
+
if #available(iOS 16.0, macOS 13.0, watchOS 9.0, tvOS 16.0, *) {
|
|
65
|
+
return compressedRepresentation.toHexString()
|
|
66
|
+
} else {
|
|
67
|
+
throw KeyError.representationUnavailable("Compressed representation is unavailable.")
|
|
68
|
+
}
|
|
69
|
+
case .compact:
|
|
70
|
+
return compactRepresentation?.toHexString() ?? ""
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public enum PrivateKeyRepresentation {
|
|
76
|
+
case raw
|
|
77
|
+
case x963
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
extension P256.Signing.PrivateKey: P256KeyProtocol {}
|
|
81
|
+
extension P256.KeyAgreement.PrivateKey: P256KeyProtocol {}
|
|
82
|
+
|
|
83
|
+
extension P256.Signing.PrivateKey {
|
|
84
|
+
/// Converts the private key into the specified string representation.
|
|
85
|
+
///
|
|
86
|
+
/// - Parameter representation: The desired representation of the key.
|
|
87
|
+
/// - Returns: A string representation of the private key in the specified format.
|
|
88
|
+
/// - Throws: `KeyError.representationUnavailable` if the desired representation is not available.
|
|
89
|
+
public func toString(representation: PrivateKeyRepresentation) throws -> String {
|
|
90
|
+
switch representation {
|
|
91
|
+
case .raw:
|
|
92
|
+
return rawRepresentation.toHexString()
|
|
93
|
+
case .x963:
|
|
94
|
+
return x963Representation.toHexString()
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
extension String {
|
|
4
|
+
public var hex: some Sequence<UInt8> {
|
|
5
|
+
self[...].hex
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
public var hexData: Data {
|
|
9
|
+
return Data(hex)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
extension Substring {
|
|
14
|
+
public var hex: some Sequence<UInt8> {
|
|
15
|
+
sequence(
|
|
16
|
+
state: self,
|
|
17
|
+
next: { remainder in
|
|
18
|
+
guard remainder.count > 2 else { return nil }
|
|
19
|
+
let nextTwo = remainder.prefix(2)
|
|
20
|
+
remainder.removeFirst(2)
|
|
21
|
+
return UInt8(nextTwo, radix: 16)
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/commonjs/client.js
CHANGED
|
@@ -29,10 +29,20 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
29
29
|
connection
|
|
30
30
|
});
|
|
31
31
|
}
|
|
32
|
-
// TODO: implement OTP
|
|
33
32
|
async submitOtpCode(args) {
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
this.eventEmitter.emit("authenticating", {
|
|
34
|
+
type: "otpVerify"
|
|
35
|
+
});
|
|
36
|
+
const publicKey = await this.stamper.init();
|
|
37
|
+
const {
|
|
38
|
+
credentialBundle
|
|
39
|
+
} = await this.request("/v1/otp", {
|
|
40
|
+
...args,
|
|
41
|
+
targetPublicKey: publicKey
|
|
42
|
+
});
|
|
43
|
+
return {
|
|
44
|
+
bundle: credentialBundle
|
|
45
|
+
};
|
|
36
46
|
}
|
|
37
47
|
async createAccount(params) {
|
|
38
48
|
if (params.type !== "email") {
|
|
@@ -48,7 +58,7 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
48
58
|
const publicKey = await this.stamper.init();
|
|
49
59
|
const response = await this.request("/v1/signup", {
|
|
50
60
|
email,
|
|
51
|
-
emailMode:
|
|
61
|
+
emailMode: params.emailMode,
|
|
52
62
|
targetPublicKey: publicKey,
|
|
53
63
|
expirationSeconds,
|
|
54
64
|
redirectParams: params.redirectParams?.toString()
|
|
@@ -60,14 +70,15 @@ class RNSignerClient extends _signer.BaseSignerClient {
|
|
|
60
70
|
type: "email"
|
|
61
71
|
});
|
|
62
72
|
let targetPublicKey = await this.stamper.init();
|
|
63
|
-
|
|
73
|
+
const response = await this.request("/v1/auth", {
|
|
64
74
|
email: params.email,
|
|
65
|
-
emailMode:
|
|
75
|
+
emailMode: params.emailMode,
|
|
66
76
|
targetPublicKey
|
|
67
77
|
});
|
|
78
|
+
return response;
|
|
68
79
|
}
|
|
69
80
|
async completeAuthWithBundle(params) {
|
|
70
|
-
if (params.authenticatingType !== "email") {
|
|
81
|
+
if (params.authenticatingType !== "email" && params.authenticatingType !== "otp") {
|
|
71
82
|
throw new Error("Unsupported authenticating type");
|
|
72
83
|
}
|
|
73
84
|
this.eventEmitter.emit("authenticating", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["require","_signer","_NativeTEKStamper","_interopRequireDefault","_zod","e","__esModule","default","RNSignerClientParamsSchema","exports","z","object","connection","custom","rootOrgId","string","optional","RNSignerClient","BaseSignerClient","stamper","NativeTEKStamper","constructor","params","parse","submitOtpCode","args","
|
|
1
|
+
{"version":3,"names":["require","_signer","_NativeTEKStamper","_interopRequireDefault","_zod","e","__esModule","default","RNSignerClientParamsSchema","exports","z","object","connection","custom","rootOrgId","string","optional","RNSignerClient","BaseSignerClient","stamper","NativeTEKStamper","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","credentialBundle","request","targetPublicKey","bundle","createAccount","Error","email","expirationSeconds","response","emailMode","redirectParams","toString","initEmailAuth","completeAuthWithBundle","authenticatingType","result","injectCredentialBundle","user","whoami","orgId","idToken","connectedEventName","oauthWithRedirect","_args","oauthWithPopup","disconnect","undefined","clear","exportWallet","_params","lookupUserWithPasskey","_user","getOauthConfig","getWebAuthnAttestation","_options","_userDetails"],"sourceRoot":"../../src","sources":["client.ts"],"mappings":";;;;;;AACAA,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAaA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AAAwB,SAAAG,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAjBxB;;AAmBO,MAAMG,0BAA0B,GAAAC,OAAA,CAAAD,0BAAA,GAAGE,MAAC,CAACC,MAAM,CAAC;EACjDC,UAAU,EAAEF,MAAC,CAACG,MAAM,CAAmB,CAAC;EACxCC,SAAS,EAAEJ,MAAC,CAACK,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACjC,CAAC,CAAC;AAIF;AACO,MAAMC,cAAc,SAASC,wBAAgB,CAAY;EACtDC,OAAO,GAAGC,yBAAgB;EAClCC,WAAWA,CAACC,MAA4B,EAAE;IACxC,MAAM;MAAEV,UAAU;MAAEE;IAAU,CAAC,GAAGN,0BAA0B,CAACe,KAAK,CAACD,MAAM,CAAC;IAE1E,KAAK,CAAC;MACJH,O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f,MAAM,IAAIlB,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EAEA,MAAeoB,UAAUA,CAAA,EAAkB;IACzC,IAAI,CAACR,IAAI,GAAGS,SAAS;IACrB,IAAI,CAACtC,OAAO,CAACuC,KAAK,CAAC,CAAC;IACpB,MAAM,IAAI,CAACvC,OAAO,CAACW,IAAI,CAAC,CAAC;EAC3B;EACS6B,YAAYA,CAACC,OAAgB,EAAoB;IACxD,MAAM,IAAIxB,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACSyB,qBAAqBA,CAACC,KAAY,EAAiB;IAC1D,MAAM,IAAI1B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACmB2B,cAAcA,CAAA,EAAyB;IACxD,MAAM,IAAI3B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACmB4B,sBAAsBA,CACvCC,QAAmC,EACnCC,YAAmC,EACI;IACvC,MAAM,IAAI9B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;AACF;AAAC3B,OAAA,CAAAQ,cAAA,GAAAA,cAAA","ignoreList":[]}
|
package/lib/commonjs/signer.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.RNAlchemySigner =
|
|
6
|
+
exports.RNAlchemySigner = RNAlchemySigner;
|
|
7
7
|
var _zod = require("zod");
|
|
8
8
|
var _signer = require("@account-kit/signer");
|
|
9
9
|
var _client = require("./client.js");
|
|
@@ -17,8 +17,11 @@ const RNAlchemySignerParamsSchema = _zod.z.object({
|
|
|
17
17
|
storage: true
|
|
18
18
|
}).optional()
|
|
19
19
|
});
|
|
20
|
-
class
|
|
20
|
+
class RNAlchemySignerSingleton extends _signer.BaseAlchemySigner {
|
|
21
21
|
constructor(params) {
|
|
22
|
+
if (!!RNAlchemySignerSingleton.instance) {
|
|
23
|
+
return RNAlchemySignerSingleton.instance;
|
|
24
|
+
}
|
|
22
25
|
const {
|
|
23
26
|
sessionConfig,
|
|
24
27
|
...params_
|
|
@@ -34,6 +37,15 @@ class RNAlchemySigner extends _signer.BaseAlchemySigner {
|
|
|
34
37
|
sessionConfig
|
|
35
38
|
});
|
|
36
39
|
}
|
|
40
|
+
static getInstance(params) {
|
|
41
|
+
if (!this.instance) {
|
|
42
|
+
this.instance = new RNAlchemySignerSingleton(params);
|
|
43
|
+
}
|
|
44
|
+
return this.instance;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function RNAlchemySigner(params) {
|
|
48
|
+
const instance = RNAlchemySignerSingleton.getInstance(params);
|
|
49
|
+
return instance;
|
|
37
50
|
}
|
|
38
|
-
exports.RNAlchemySigner = RNAlchemySigner;
|
|
39
51
|
//# sourceMappingURL=signer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_zod","require","_signer","_client","RNAlchemySignerParamsSchema","z","object","client","custom","or","RNSignerClientParamsSchema","extend","sessionConfig","SessionManagerParamsSchema","omit","storage","optional","
|
|
1
|
+
{"version":3,"names":["_zod","require","_signer","_client","RNAlchemySignerParamsSchema","z","object","client","custom","or","RNSignerClientParamsSchema","extend","sessionConfig","SessionManagerParamsSchema","omit","storage","optional","RNAlchemySignerSingleton","BaseAlchemySigner","constructor","params","instance","params_","parse","RNSignerClient","getInstance","RNAlchemySigner"],"sourceRoot":"../../src","sources":["signer.ts"],"mappings":";;;;;;AAAA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAKA,IAAAE,OAAA,GAAAF,OAAA;AADA;;AAGA,MAAMG,2BAA2B,GAAGC,MAAC,CAClCC,MAAM,CAAC;EACNC,MAAM,EAAEF,MAAC,CAACG,MAAM,CAAiB,CAAC,CAACC,EAAE,CAACC,kCAA0B;AAClE,CAAC,CAAC,CACDC,MAAM,CAAC;EACNC,aAAa,EAAEC,kCAA0B,CAACC,IAAI,CAAC;IAC7CP,MAAM,EAAE,IAAI;IACZQ,OAAO,EAAE;EACX,CAAC,CAAC,CAACC,QAAQ,CAAC;AACd,CAAC,CAAC;AAIJ,MAAMC,wBAAwB,SAASC,yBAAiB,CAAiB;EAG/DC,WAAWA,CAACC,MAA6B,EAAE;IACjD,IAAI,CAAC,CAACH,wBAAwB,CAACI,QAAQ,EAAE;MACvC,OAAOJ,wBAAwB,CAACI,QAAQ;IAC1C;IAEA,MAAM;MAAET,aAAa;MAAE,GAAGU;IAAQ,CAAC,GACjClB,2BAA2B,CAACmB,KAAK,CAACH,MAAM,CAAC;IAE3C,IAAIb,MAAsB;IAE1B,IAAI,YAAY,IAAIe,OAAO,CAACf,MAAM,EAAE;MAClCA,MAAM,GAAG,IAAIiB,sBAAc,CAACF,OAAO,CAACf,MAAM,CAAC;IAC7C,CAAC,MAAM;MACLA,MAAM,GAAGe,OAAO,CAACf,MAAM;IACzB;IACA,KAAK,CAAC;MACJA,MAAM;MACNK;IACF,CAAC,CAAC;EACJ;EAEA,OAAca,WAAWA,CAACL,MAA6B,EAAE;IACvD,IAAI,CAAC,IAAI,CAACC,QAAQ,EAAE;MAClB,IAAI,CAACA,QAAQ,GAAG,IAAIJ,wBAAwB,CAACG,MAAM,CAAC;IACtD;IACA,OAAO,IAAI,CAACC,QAAQ;EACtB;AACF;AAEO,SAASK,eAAeA,CAACN,MAA6B,EAAE;EAC7D,MAAMC,QAAQ,GAAGJ,wBAAwB,CAACQ,WAAW,CAACL,MAAM,CAAC;EAE7D,OAAOC,QAAQ;AACjB","ignoreList":[]}
|
package/lib/module/client.js
CHANGED
|
@@ -23,10 +23,20 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
23
23
|
connection
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
// TODO: implement OTP
|
|
27
26
|
async submitOtpCode(args) {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
this.eventEmitter.emit("authenticating", {
|
|
28
|
+
type: "otpVerify"
|
|
29
|
+
});
|
|
30
|
+
const publicKey = await this.stamper.init();
|
|
31
|
+
const {
|
|
32
|
+
credentialBundle
|
|
33
|
+
} = await this.request("/v1/otp", {
|
|
34
|
+
...args,
|
|
35
|
+
targetPublicKey: publicKey
|
|
36
|
+
});
|
|
37
|
+
return {
|
|
38
|
+
bundle: credentialBundle
|
|
39
|
+
};
|
|
30
40
|
}
|
|
31
41
|
async createAccount(params) {
|
|
32
42
|
if (params.type !== "email") {
|
|
@@ -42,7 +52,7 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
42
52
|
const publicKey = await this.stamper.init();
|
|
43
53
|
const response = await this.request("/v1/signup", {
|
|
44
54
|
email,
|
|
45
|
-
emailMode:
|
|
55
|
+
emailMode: params.emailMode,
|
|
46
56
|
targetPublicKey: publicKey,
|
|
47
57
|
expirationSeconds,
|
|
48
58
|
redirectParams: params.redirectParams?.toString()
|
|
@@ -54,14 +64,15 @@ export class RNSignerClient extends BaseSignerClient {
|
|
|
54
64
|
type: "email"
|
|
55
65
|
});
|
|
56
66
|
let targetPublicKey = await this.stamper.init();
|
|
57
|
-
|
|
67
|
+
const response = await this.request("/v1/auth", {
|
|
58
68
|
email: params.email,
|
|
59
|
-
emailMode:
|
|
69
|
+
emailMode: params.emailMode,
|
|
60
70
|
targetPublicKey
|
|
61
71
|
});
|
|
72
|
+
return response;
|
|
62
73
|
}
|
|
63
74
|
async completeAuthWithBundle(params) {
|
|
64
|
-
if (params.authenticatingType !== "email") {
|
|
75
|
+
if (params.authenticatingType !== "email" && params.authenticatingType !== "otp") {
|
|
65
76
|
throw new Error("Unsupported authenticating type");
|
|
66
77
|
}
|
|
67
78
|
this.eventEmitter.emit("authenticating", {
|
package/lib/module/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["BaseSignerClient","NativeTEKStamper","z","RNSignerClientParamsSchema","object","connection","custom","rootOrgId","string","optional","RNSignerClient","stamper","constructor","params","parse","submitOtpCode","args","
|
|
1
|
+
{"version":3,"names":["BaseSignerClient","NativeTEKStamper","z","RNSignerClientParamsSchema","object","connection","custom","rootOrgId","string","optional","RNSignerClient","stamper","constructor","params","parse","submitOtpCode","args","eventEmitter","emit","type","publicKey","init","credentialBundle","request","targetPublicKey","bundle","createAccount","Error","email","expirationSeconds","response","emailMode","redirectParams","toString","initEmailAuth","completeAuthWithBundle","authenticatingType","result","injectCredentialBundle","user","whoami","orgId","idToken","connectedEventName","oauthWithRedirect","_args","oauthWithPopup","disconnect","undefined","clear","exportWallet","_params","lookupUserWithPasskey","_user","getOauthConfig","getWebAuthnAttestation","_options","_userDetails"],"sourceRoot":"../../src","sources":["client.ts"],"mappings":";;AAAA;AACA,OAAO,uCAAoC;AAE3C,SACEA,gBAAgB,QAWX,qBAAqB;AAC5B,OAAOC,gBAAgB,MAAM,uBAAoB;AACjD,SAASC,CAAC,QAAQ,KAAK;AAEvB,OAAO,MAAMC,0BAA0B,GAAGD,CAAC,CAACE,MAAM,CAAC;EACjDC,UAAU,EAAEH,CAAC,CAACI,MAAM,CAAmB,CAAC;EACxCC,SAAS,EAAEL,CAAC,CAACM,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC;AACjC,CAAC,CAAC;AAIF;AACA,OAAO,MAAMC,cAAc,SAASV,gBAAgB,CAAY;EACtDW,OAAO,GAAGV,gBAAgB;EAClCW,WAAWA,CAACC,MAA4B,EAAE;IACxC,MAAM;MAAER,UAAU;MAAEE;IAAU,CAAC,GAAGJ,0BAA0B,CAACW,KAAK,CAACD,MAAM,CAAC;IAE1E,KAAK,CAAC;MACJF,OAAO,EAAEV,gBAAgB;MACzBM,SAAS,EAAEA,SAAS,IAAI,sCAAsC;MAC9DF;IACF,CAAC,CAAC;EACJ;EAEA,MAAeU,aAAaA,CAC1BC,IAAwC,EACX;IAC7B,IAAI,CAACC,YAAY,CAACC,IAAI,CAAC,gBAAgB,EAAE;MAAEC,IAAI,EAAE;IAAY,CAAC,CAAC;IAC/D,MAAMC,SAAS,GAAG,MAAM,IAAI,CAACT,OAAO,CAACU,IAAI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,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACSyB,qBAAqBA,CAACC,KAAY,EAAiB;IAC1D,MAAM,IAAI1B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACmB2B,cAAcA,CAAA,EAAyB;IACxD,MAAM,IAAI3B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;EACmB4B,sBAAsBA,CACvCC,QAAmC,EACnCC,YAAmC,EACI;IACvC,MAAM,IAAI9B,KAAK,CAAC,yBAAyB,CAAC;EAC5C;AACF","ignoreList":[]}
|
package/lib/module/signer.js
CHANGED
|
@@ -12,8 +12,11 @@ const RNAlchemySignerParamsSchema = z.object({
|
|
|
12
12
|
storage: true
|
|
13
13
|
}).optional()
|
|
14
14
|
});
|
|
15
|
-
|
|
15
|
+
class RNAlchemySignerSingleton extends BaseAlchemySigner {
|
|
16
16
|
constructor(params) {
|
|
17
|
+
if (!!RNAlchemySignerSingleton.instance) {
|
|
18
|
+
return RNAlchemySignerSingleton.instance;
|
|
19
|
+
}
|
|
17
20
|
const {
|
|
18
21
|
sessionConfig,
|
|
19
22
|
...params_
|
|
@@ -29,5 +32,15 @@ export class RNAlchemySigner extends BaseAlchemySigner {
|
|
|
29
32
|
sessionConfig
|
|
30
33
|
});
|
|
31
34
|
}
|
|
35
|
+
static getInstance(params) {
|
|
36
|
+
if (!this.instance) {
|
|
37
|
+
this.instance = new RNAlchemySignerSingleton(params);
|
|
38
|
+
}
|
|
39
|
+
return this.instance;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
export function RNAlchemySigner(params) {
|
|
43
|
+
const instance = RNAlchemySignerSingleton.getInstance(params);
|
|
44
|
+
return instance;
|
|
32
45
|
}
|
|
33
46
|
//# sourceMappingURL=signer.js.map
|
package/lib/module/signer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["z","BaseAlchemySigner","SessionManagerParamsSchema","RNSignerClient","RNSignerClientParamsSchema","RNAlchemySignerParamsSchema","object","client","custom","or","extend","sessionConfig","omit","storage","optional","
|
|
1
|
+
{"version":3,"names":["z","BaseAlchemySigner","SessionManagerParamsSchema","RNSignerClient","RNSignerClientParamsSchema","RNAlchemySignerParamsSchema","object","client","custom","or","extend","sessionConfig","omit","storage","optional","RNAlchemySignerSingleton","constructor","params","instance","params_","parse","getInstance","RNAlchemySigner"],"sourceRoot":"../../src","sources":["signer.ts"],"mappings":";;AAAA,SAASA,CAAC,QAAQ,KAAK;AACvB,SACEC,iBAAiB,EACjBC,0BAA0B,QACrB,qBAAqB;AAC5B;AACA,SAASC,cAAc,EAAEC,0BAA0B,QAAQ,aAAU;AAErE,MAAMC,2BAA2B,GAAGL,CAAC,CAClCM,MAAM,CAAC;EACNC,MAAM,EAAEP,CAAC,CAACQ,MAAM,CAAiB,CAAC,CAACC,EAAE,CAACL,0BAA0B;AAClE,CAAC,CAAC,CACDM,MAAM,CAAC;EACNC,aAAa,EAAET,0BAA0B,CAACU,IAAI,CAAC;IAC7CL,MAAM,EAAE,IAAI;IACZM,OAAO,EAAE;EACX,CAAC,CAAC,CAACC,QAAQ,CAAC;AACd,CAAC,CAAC;AAIJ,MAAMC,wBAAwB,SAASd,iBAAiB,CAAiB;EAG/De,WAAWA,CAACC,MAA6B,EAAE;IACjD,IAAI,CAAC,CAACF,wBAAwB,CAACG,QAAQ,EAAE;MACvC,OAAOH,wBAAwB,CAACG,QAAQ;IAC1C;IAEA,MAAM;MAAEP,aAAa;MAAE,GAAGQ;IAAQ,CAAC,GACjCd,2BAA2B,CAACe,KAAK,CAACH,MAAM,CAAC;IAE3C,IAAIV,MAAsB;IAE1B,IAAI,YAAY,IAAIY,OAAO,CAACZ,MAAM,EAAE;MAClCA,MAAM,GAAG,IAAIJ,cAAc,CAACgB,OAAO,CAACZ,MAAM,CAAC;IAC7C,CAAC,MAAM;MACLA,MAAM,GAAGY,OAAO,CAACZ,MAAM;IACzB;IACA,KAAK,CAAC;MACJA,MAAM;MACNI;IACF,CAAC,CAAC;EACJ;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,CAAC,EAAE,MAAM,CAAC;KAClB,GAAG,OAAO,CAAC,IAAI,CAAC;IAsBR,iBAAiB,CACxB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,UAAU,CAAA;KAAE,CAAC,GAChD,OAAO,CAAC,KAAK,CAAC;IAGR,cAAc,CACrB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAID,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAGhD,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;cAGxC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;cAGtC,sBAAsB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,4BAA4B,CAAC;CAGzC"}
|
|
@@ -178,8 +178,6 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
178
178
|
} | undefined;
|
|
179
179
|
}>;
|
|
180
180
|
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
181
|
-
export declare
|
|
182
|
-
constructor(params: RNAlchemySignerParams);
|
|
183
|
-
}
|
|
181
|
+
export declare function RNAlchemySigner(params: RNAlchemySignerParams): BaseAlchemySigner<RNSignerClient>;
|
|
184
182
|
export {};
|
|
185
183
|
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAJxC,CAAC;AAEL,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAkChF,wBAAgB,eAAe,CAAC,MAAM,EAAE,qBAAqB,qCAI5D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EACL,gBAAgB,EAChB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,IAAI,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAGrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAG9E,qBAAa,cAAe,SAAQ,gBAAgB,CAAC,SAAS,CAAC;IAC7D,OAAO,CAAC,OAAO,CAAoB;gBACvB,MAAM,EAAE,oBAAoB;IAUzB,aAAa,CAC1B,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE,iBAAiB,CAAC,GACvC,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,oCAAoC,CAAC;AAE5C,OAAO,EACL,gBAAgB,EAChB,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,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AAC,GAChD,OAAO,CAAC,KAAK,CAAC;IAGR,cAAc,CACrB,KAAK,EAAE,OAAO,CAAC,WAAW,EAAE;QAAE,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAID,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAKjC,YAAY,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAGhD,qBAAqB,CAAC,KAAK,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;cAGxC,cAAc,IAAI,OAAO,CAAC,WAAW,CAAC;cAGtC,sBAAsB,CACvC,QAAQ,EAAE,yBAAyB,EACnC,YAAY,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,GAClC,OAAO,CAAC,4BAA4B,CAAC;CAGzC"}
|
|
@@ -178,8 +178,6 @@ declare const RNAlchemySignerParamsSchema: z.ZodObject<{
|
|
|
178
178
|
} | undefined;
|
|
179
179
|
}>;
|
|
180
180
|
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
181
|
-
export declare
|
|
182
|
-
constructor(params: RNAlchemySignerParams);
|
|
183
|
-
}
|
|
181
|
+
export declare function RNAlchemySigner(params: RNAlchemySignerParams): BaseAlchemySigner<RNSignerClient>;
|
|
184
182
|
export {};
|
|
185
183
|
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../../../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,iBAAiB,EAElB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,cAAc,EAA8B,MAAM,UAAU,CAAC;AAEtE,QAAA,MAAM,2BAA2B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,MAAM,EAAE,qBAAqB,qCAI5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@account-kit/react-native-signer",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.9.0",
|
|
4
|
+
"author": "Alchemy",
|
|
4
5
|
"description": "React Native compatible Account Kit signer",
|
|
5
6
|
"source": "./src/index.tsx",
|
|
6
7
|
"main": "./lib/commonjs/index.js",
|
|
@@ -63,8 +64,8 @@
|
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"@commitlint/config-conventional": "^17.0.2",
|
|
65
66
|
"@evilmartians/lefthook": "^1.5.0",
|
|
66
|
-
"@react-native-community/cli": "15.0.
|
|
67
|
-
"@react-native/eslint-config": "^0.
|
|
67
|
+
"@react-native-community/cli": "15.0.1",
|
|
68
|
+
"@react-native/eslint-config": "^0.76.5",
|
|
68
69
|
"@release-it/conventional-changelog": "^5.0.0",
|
|
69
70
|
"@types/jest": "^29.5.5",
|
|
70
71
|
"@types/react": "^18.2.44",
|
|
@@ -76,7 +77,7 @@
|
|
|
76
77
|
"jest": "^29.7.0",
|
|
77
78
|
"prettier": "^3.0.3",
|
|
78
79
|
"react": "18.3.1",
|
|
79
|
-
"react-native": "0.76.
|
|
80
|
+
"react-native": "0.76.5",
|
|
80
81
|
"react-native-builder-bob": "^0.30.3",
|
|
81
82
|
"react-native-mmkv": "^3.1.0",
|
|
82
83
|
"release-it": "^15.0.0",
|
|
@@ -146,9 +147,9 @@
|
|
|
146
147
|
"version": "0.42.2"
|
|
147
148
|
},
|
|
148
149
|
"dependencies": {
|
|
149
|
-
"@aa-sdk/core": "^4.
|
|
150
|
-
"@account-kit/signer": "^4.
|
|
150
|
+
"@aa-sdk/core": "^4.9.0",
|
|
151
|
+
"@account-kit/signer": "^4.9.0",
|
|
151
152
|
"viem": "^2.21.40"
|
|
152
153
|
},
|
|
153
|
-
"gitHead": "
|
|
154
|
+
"gitHead": "9cd4dc759879defa6ac90f1ae7f8a378d9d1666f"
|
|
154
155
|
}
|
package/src/client.ts
CHANGED
|
@@ -36,12 +36,19 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
36
36
|
connection,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
override async submitOtpCode(
|
|
41
41
|
args: Omit<OtpParams, "targetPublicKey">
|
|
42
42
|
): Promise<{ bundle: string }> {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
this.eventEmitter.emit("authenticating", { type: "otpVerify" });
|
|
44
|
+
const publicKey = await this.stamper.init();
|
|
45
|
+
|
|
46
|
+
const { credentialBundle } = await this.request("/v1/otp", {
|
|
47
|
+
...args,
|
|
48
|
+
targetPublicKey: publicKey,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
return { bundle: credentialBundle };
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
override async createAccount(
|
|
@@ -57,7 +64,7 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
57
64
|
|
|
58
65
|
const response = await this.request("/v1/signup", {
|
|
59
66
|
email,
|
|
60
|
-
emailMode:
|
|
67
|
+
emailMode: params.emailMode,
|
|
61
68
|
targetPublicKey: publicKey,
|
|
62
69
|
expirationSeconds,
|
|
63
70
|
redirectParams: params.redirectParams?.toString(),
|
|
@@ -72,11 +79,13 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
72
79
|
this.eventEmitter.emit("authenticating", { type: "email" });
|
|
73
80
|
let targetPublicKey = await this.stamper.init();
|
|
74
81
|
|
|
75
|
-
|
|
82
|
+
const response = await this.request("/v1/auth", {
|
|
76
83
|
email: params.email,
|
|
77
|
-
emailMode:
|
|
84
|
+
emailMode: params.emailMode,
|
|
78
85
|
targetPublicKey,
|
|
79
86
|
});
|
|
87
|
+
|
|
88
|
+
return response;
|
|
80
89
|
}
|
|
81
90
|
|
|
82
91
|
override async completeAuthWithBundle(params: {
|
|
@@ -86,7 +95,10 @@ export class RNSignerClient extends BaseSignerClient<undefined> {
|
|
|
86
95
|
authenticatingType: AuthenticatingEventMetadata["type"];
|
|
87
96
|
idToken?: string;
|
|
88
97
|
}): Promise<User> {
|
|
89
|
-
if (
|
|
98
|
+
if (
|
|
99
|
+
params.authenticatingType !== "email" &&
|
|
100
|
+
params.authenticatingType !== "otp"
|
|
101
|
+
) {
|
|
90
102
|
throw new Error("Unsupported authenticating type");
|
|
91
103
|
}
|
|
92
104
|
|
package/src/signer.ts
CHANGED
|
@@ -19,8 +19,14 @@ const RNAlchemySignerParamsSchema = z
|
|
|
19
19
|
|
|
20
20
|
export type RNAlchemySignerParams = z.input<typeof RNAlchemySignerParamsSchema>;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
class RNAlchemySignerSingleton extends BaseAlchemySigner<RNSignerClient> {
|
|
23
|
+
private static instance: BaseAlchemySigner<RNSignerClient>;
|
|
24
|
+
|
|
25
|
+
private constructor(params: RNAlchemySignerParams) {
|
|
26
|
+
if (!!RNAlchemySignerSingleton.instance) {
|
|
27
|
+
return RNAlchemySignerSingleton.instance;
|
|
28
|
+
}
|
|
29
|
+
|
|
24
30
|
const { sessionConfig, ...params_ } =
|
|
25
31
|
RNAlchemySignerParamsSchema.parse(params);
|
|
26
32
|
|
|
@@ -36,4 +42,17 @@ export class RNAlchemySigner extends BaseAlchemySigner<RNSignerClient> {
|
|
|
36
42
|
sessionConfig,
|
|
37
43
|
});
|
|
38
44
|
}
|
|
45
|
+
|
|
46
|
+
public static getInstance(params: RNAlchemySignerParams) {
|
|
47
|
+
if (!this.instance) {
|
|
48
|
+
this.instance = new RNAlchemySignerSingleton(params);
|
|
49
|
+
}
|
|
50
|
+
return this.instance;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function RNAlchemySigner(params: RNAlchemySignerParams) {
|
|
55
|
+
const instance = RNAlchemySignerSingleton.getInstance(params);
|
|
56
|
+
|
|
57
|
+
return instance;
|
|
39
58
|
}
|
package/ios/ReactNativeSigner.h
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
3
|
-
#import "RNReactNativeSignerSpec.h"
|
|
4
|
-
|
|
5
|
-
@interface ReactNativeSigner : NSObject <NativeReactNativeSignerSpec>
|
|
6
|
-
#else
|
|
7
|
-
#import <React/RCTBridgeModule.h>
|
|
8
|
-
|
|
9
|
-
@interface ReactNativeSigner : NSObject <RCTBridgeModule>
|
|
10
|
-
#endif
|
|
11
|
-
|
|
12
|
-
@end
|
package/ios/ReactNativeSigner.mm
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#import "ReactNativeSigner.h"
|
|
2
|
-
|
|
3
|
-
@implementation ReactNativeSigner
|
|
4
|
-
RCT_EXPORT_MODULE()
|
|
5
|
-
|
|
6
|
-
// Don't compile this code when we build for the old architecture.
|
|
7
|
-
#ifdef RCT_NEW_ARCH_ENABLED
|
|
8
|
-
- (NSNumber *)multiply:(double)a b:(double)b {
|
|
9
|
-
NSNumber *result = @(a * b);
|
|
10
|
-
|
|
11
|
-
return result;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
15
|
-
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
16
|
-
{
|
|
17
|
-
return std::make_shared<facebook::react::NativeReactNativeSignerSpecJSI>(params);
|
|
18
|
-
}
|
|
19
|
-
#endif
|
|
20
|
-
|
|
21
|
-
@end
|