@novastera-oss/nitro-metamask 0.6.3 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NitroMetamask.podspec +12 -3
- package/README.md +3 -1
- package/android/build.gradle +14 -32
- package/android/cargo-ecies.gradle +60 -88
- package/android/src/main/aidl/io/metamask/nativesdk/IMessegeService.aidl +8 -0
- package/android/src/main/aidl/io/metamask/nativesdk/IMessegeServiceCallback.aidl +8 -0
- package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridNitroMetamask.kt +101 -3
- package/android/src/main/java/io/metamask/androidsdk/AnyRequest.kt +8 -0
- package/android/src/main/java/io/metamask/androidsdk/ClientMessageServiceCallback.kt +12 -0
- package/android/src/main/java/io/metamask/androidsdk/ClientServiceConnection.kt +42 -0
- package/android/src/main/java/io/metamask/androidsdk/CommunicationClient.kt +525 -0
- package/android/src/main/java/io/metamask/androidsdk/CommunicationClientModule.kt +47 -0
- package/android/src/main/java/io/metamask/androidsdk/CommunicationClientModuleInterface.kt +11 -0
- package/android/src/main/java/io/metamask/androidsdk/Constants.kt +5 -0
- package/android/src/main/java/io/metamask/androidsdk/Crypto.kt +35 -0
- package/android/src/main/java/io/metamask/androidsdk/DappMetadata.kt +36 -0
- package/android/src/main/java/io/metamask/androidsdk/Encryption.kt +9 -0
- package/android/src/main/java/io/metamask/androidsdk/ErrorType.kt +41 -0
- package/android/src/main/java/io/metamask/androidsdk/Ethereum.kt +328 -0
- package/android/src/main/java/io/metamask/androidsdk/EthereumEventCallback.kt +6 -0
- package/android/src/main/java/io/metamask/androidsdk/EthereumMethod.kt +80 -0
- package/android/src/main/java/io/metamask/androidsdk/EthereumRequest.kt +7 -0
- package/android/src/main/java/io/metamask/androidsdk/EthereumState.kt +7 -0
- package/android/src/main/java/io/metamask/androidsdk/KeyExchange.kt +77 -0
- package/android/src/main/java/io/metamask/androidsdk/KeyExchangeMessageType.kt +20 -0
- package/android/src/main/java/io/metamask/androidsdk/KeyStorage.kt +122 -0
- package/android/src/main/java/io/metamask/androidsdk/Logger.kt +18 -0
- package/android/src/main/java/io/metamask/androidsdk/Message.kt +3 -0
- package/android/src/main/java/io/metamask/androidsdk/MessageType.kt +11 -0
- package/android/src/main/java/io/metamask/androidsdk/OriginatorInfo.kt +12 -0
- package/android/src/main/java/io/metamask/androidsdk/RequestError.kt +8 -0
- package/android/src/main/java/io/metamask/androidsdk/RequestInfo.kt +9 -0
- package/android/src/main/java/io/metamask/androidsdk/Result.kt +11 -0
- package/android/src/main/java/io/metamask/androidsdk/RpcRequest.kt +7 -0
- package/android/src/main/java/io/metamask/androidsdk/SDKInfo.kt +6 -0
- package/android/src/main/java/io/metamask/androidsdk/SDKOptions.kt +6 -0
- package/android/src/main/java/io/metamask/androidsdk/SecureStorage.kt +9 -0
- package/android/src/main/java/io/metamask/androidsdk/SessionConfig.kt +10 -0
- package/android/src/main/java/io/metamask/androidsdk/SessionManager.kt +92 -0
- package/android/src/main/java/io/metamask/androidsdk/SubmittedRequest.kt +8 -0
- package/android/src/main/java/io/metamask/androidsdk/TimeStampGenerator.kt +7 -0
- package/android/src/main/jniLibs/arm64-v8a/libecies.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libecies.so +0 -0
- package/android/src/main/jniLibs/x86/libecies.so +0 -0
- package/android/src/main/jniLibs/x86_64/libecies.so +0 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/CancellationStateMachineTest.kt +128 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/ChainIdParsingTest.kt +65 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/ConfigureStateMachineTest.kt +140 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/ConnectSignJsonTest.kt +76 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/MetaMaskInstallationCheckTest.kt +42 -0
- package/android/src/test/java/com/margelo/nitro/nitrometamask/PersonalSignParamsTest.kt +75 -0
- package/ios/Frameworks/Ecies.xcframework/Info.plist +47 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64/Headers/ecies.h +20 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64/Headers/module.modulemap +4 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64/libecies.a +0 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64-simulator/Headers/ecies.h +20 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64-simulator/Headers/module.modulemap +4 -0
- package/ios/Frameworks/Ecies.xcframework/ios-arm64-simulator/libecies.a +0 -0
- package/ios/HybridNitroMetamask.swift +119 -54
- package/ios/NitroMetamaskTests/CancellationStateMachineTests.swift +150 -0
- package/ios/NitroMetamaskTests/ChainIdParsingTests.swift +117 -0
- package/ios/NitroMetamaskTests/ConfigureStateMachineTests.swift +174 -0
- package/ios/NitroMetamaskTests/ConnectSignJsonTests.swift +168 -0
- package/ios/NitroMetamaskTests/DefaultDappUrlTests.swift +80 -0
- package/ios/NitroMetamaskTests/PersonalSignParamsTests.swift +101 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/CommClient.swift +43 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/CommClientFactory.swift +17 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/CommLayer.swift +36 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/DeeplinkCommLayer/Deeplink.swift +26 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/DeeplinkCommLayer/DeeplinkClient.swift +199 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/DeeplinkCommLayer/DeeplinkManager.swift +83 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/DeeplinkCommLayer/String.swift +48 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/DeeplinkCommLayer/URLOpener.swift +19 -0
- package/ios/metamask-ios-sdk/CommunicationLayer/SocketClient.swift +27 -0
- package/ios/metamask-ios-sdk/Crypto/Crypto.swift +72 -0
- package/ios/metamask-ios-sdk/Crypto/Encoding.swift +15 -0
- package/ios/metamask-ios-sdk/Crypto/KeyExchange.swift +236 -0
- package/ios/metamask-ios-sdk/DeviceInfo/DeviceInfo.swift +11 -0
- package/ios/metamask-ios-sdk/Ethereum/AppMetadata.swift +28 -0
- package/ios/metamask-ios-sdk/Ethereum/ErrorType.swift +62 -0
- package/ios/metamask-ios-sdk/Ethereum/Ethereum.swift +810 -0
- package/ios/metamask-ios-sdk/Ethereum/EthereumMethod.swift +111 -0
- package/ios/metamask-ios-sdk/Ethereum/EthereumRequest.swift +40 -0
- package/ios/metamask-ios-sdk/Ethereum/EthereumWrapper.swift +10 -0
- package/ios/metamask-ios-sdk/Ethereum/RPCRequest.swift +14 -0
- package/ios/metamask-ios-sdk/Ethereum/RequestError.swift +88 -0
- package/ios/metamask-ios-sdk/Ethereum/ResponseMethod.swift +22 -0
- package/ios/metamask-ios-sdk/Ethereum/SubmitRequest.swift +26 -0
- package/ios/metamask-ios-sdk/Ethereum/TimestampGenerator.swift +16 -0
- package/ios/metamask-ios-sdk/Extensions/NSRecursiveLock.swift +14 -0
- package/ios/metamask-ios-sdk/Extensions/Notification.swift +10 -0
- package/ios/metamask-ios-sdk/Logger/Logging.swift +27 -0
- package/ios/metamask-ios-sdk/Models/AddChainParameters.swift +35 -0
- package/ios/metamask-ios-sdk/Models/Event.swift +19 -0
- package/ios/metamask-ios-sdk/Models/Mappable.swift +40 -0
- package/ios/metamask-ios-sdk/Models/NativeCurrency.swift +25 -0
- package/ios/metamask-ios-sdk/Models/OriginatorInfo.swift +26 -0
- package/ios/metamask-ios-sdk/Models/RequestInfo.swift +18 -0
- package/ios/metamask-ios-sdk/Models/SignContract.swift +48 -0
- package/ios/metamask-ios-sdk/Models/Typealiases.swift +9 -0
- package/ios/metamask-ios-sdk/Persistence/SecureStore.swift +134 -0
- package/ios/metamask-ios-sdk/Persistence/SessionConfig.swift +24 -0
- package/ios/metamask-ios-sdk/Persistence/SessionManager.swift +56 -0
- package/ios/metamask-ios-sdk/SDK/Dependencies.swift +35 -0
- package/ios/metamask-ios-sdk/SDK/MetaMaskSDK.swift +215 -0
- package/ios/metamask-ios-sdk/SDK/SDKInfo.swift +37 -0
- package/ios/metamask-ios-sdk/SDK/SDKOptions.swift +16 -0
- package/lib/commonjs/index.js +50 -3
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +49 -3
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/__tests__/parseNitroError.test.d.ts +2 -0
- package/lib/typescript/src/__tests__/parseNitroError.test.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +43 -3
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts +29 -1
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts.map +1 -1
- package/package.json +21 -12
- package/react-native.config.js +5 -0
- package/rust/ecies-jni/Cargo.lock +50 -86
- package/rust/ecies-jni/Cargo.toml +1 -1
- package/rust/ecies-jni/src/lib.rs +164 -100
- package/src/__tests__/parseNitroError.test.ts +35 -0
- package/src/index.ts +53 -5
- package/src/specs/nitro-metamask.nitro.ts +29 -1
- package/scripts/verify-16k-page-alignment.py +0 -117
- package/scripts/verify-16k-page-alignment.sh +0 -5
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
package com.margelo.nitro.nitrometamask
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.assertFalse
|
|
4
|
+
import org.junit.Assert.assertTrue
|
|
5
|
+
import org.junit.Assert.assertEquals
|
|
6
|
+
import org.junit.Test
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Unit tests for the configure() state machine logic in HybridNitroMetamask.
|
|
10
|
+
*
|
|
11
|
+
* Tests the idempotence and invalidation behavior of configure() without
|
|
12
|
+
* requiring Android SDK dependencies.
|
|
13
|
+
*
|
|
14
|
+
* Property 3: configure() with same values is a no-op (SDK instance unchanged)
|
|
15
|
+
* Validates: Requirements 1.7
|
|
16
|
+
*
|
|
17
|
+
* Property 4: configure() with different values invalidates SDK instance
|
|
18
|
+
* Validates: Requirements 1.6
|
|
19
|
+
*/
|
|
20
|
+
class ConfigureStateMachineTest {
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Minimal replica of the configure() state machine from HybridNitroMetamask.
|
|
24
|
+
* Mirrors the production logic so tests validate the real algorithm.
|
|
25
|
+
*/
|
|
26
|
+
private class ConfigureStateMachine {
|
|
27
|
+
var dappUrl: String? = null
|
|
28
|
+
var deepLinkScheme: String? = null
|
|
29
|
+
var sdkInvalidated: Boolean = false
|
|
30
|
+
|
|
31
|
+
fun configure(url: String?, scheme: String?) {
|
|
32
|
+
val urlToUse = url ?: "https://novastera.com"
|
|
33
|
+
val schemeToUse = scheme ?: "nitrometamask"
|
|
34
|
+
var changed = false
|
|
35
|
+
if (this.dappUrl != urlToUse) { this.dappUrl = urlToUse; changed = true }
|
|
36
|
+
if (this.deepLinkScheme != schemeToUse) { this.deepLinkScheme = schemeToUse; changed = true }
|
|
37
|
+
if (changed) sdkInvalidated = true
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// -------------------------------------------------------------------------
|
|
42
|
+
// Property 3: configure() idempotence — same values must not invalidate SDK
|
|
43
|
+
// -------------------------------------------------------------------------
|
|
44
|
+
|
|
45
|
+
@Test
|
|
46
|
+
fun `configure with same url and scheme twice does not invalidate SDK`() {
|
|
47
|
+
val sm = ConfigureStateMachine()
|
|
48
|
+
sm.configure("https://example.com", "myapp")
|
|
49
|
+
|
|
50
|
+
// Reset the flag to simulate SDK being alive after first configure
|
|
51
|
+
sm.sdkInvalidated = false
|
|
52
|
+
|
|
53
|
+
// Second call with identical values — must be a no-op
|
|
54
|
+
sm.configure("https://example.com", "myapp")
|
|
55
|
+
|
|
56
|
+
assertFalse("SDK should NOT be invalidated when configure is called with same values", sm.sdkInvalidated)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Test
|
|
60
|
+
fun `configure with null values twice uses defaults and does not invalidate SDK`() {
|
|
61
|
+
val sm = ConfigureStateMachine()
|
|
62
|
+
sm.configure(null, null)
|
|
63
|
+
|
|
64
|
+
sm.sdkInvalidated = false
|
|
65
|
+
|
|
66
|
+
sm.configure(null, null)
|
|
67
|
+
|
|
68
|
+
assertFalse("SDK should NOT be invalidated when configure is called with same null values", sm.sdkInvalidated)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Test
|
|
72
|
+
fun `configure stores correct default url when called with null`() {
|
|
73
|
+
val sm = ConfigureStateMachine()
|
|
74
|
+
sm.configure(null, null)
|
|
75
|
+
|
|
76
|
+
assertEquals("Default dapp URL should be https://novastera.com", "https://novastera.com", sm.dappUrl)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// -------------------------------------------------------------------------
|
|
80
|
+
// Property 4: configure() invalidation — different values must invalidate SDK
|
|
81
|
+
// -------------------------------------------------------------------------
|
|
82
|
+
|
|
83
|
+
@Test
|
|
84
|
+
fun `configure with different url invalidates SDK`() {
|
|
85
|
+
val sm = ConfigureStateMachine()
|
|
86
|
+
sm.configure("https://first.com", "myapp")
|
|
87
|
+
|
|
88
|
+
sm.sdkInvalidated = false
|
|
89
|
+
|
|
90
|
+
sm.configure("https://second.com", "myapp")
|
|
91
|
+
|
|
92
|
+
assertTrue("SDK should be invalidated when dappUrl changes", sm.sdkInvalidated)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
@Test
|
|
96
|
+
fun `configure with different scheme invalidates SDK`() {
|
|
97
|
+
val sm = ConfigureStateMachine()
|
|
98
|
+
sm.configure("https://example.com", "scheme-one")
|
|
99
|
+
|
|
100
|
+
sm.sdkInvalidated = false
|
|
101
|
+
|
|
102
|
+
sm.configure("https://example.com", "scheme-two")
|
|
103
|
+
|
|
104
|
+
assertTrue("SDK should be invalidated when deepLinkScheme changes", sm.sdkInvalidated)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Test
|
|
108
|
+
fun `configure with both url and scheme changed invalidates SDK`() {
|
|
109
|
+
val sm = ConfigureStateMachine()
|
|
110
|
+
sm.configure("https://first.com", "scheme-one")
|
|
111
|
+
|
|
112
|
+
sm.sdkInvalidated = false
|
|
113
|
+
|
|
114
|
+
sm.configure("https://second.com", "scheme-two")
|
|
115
|
+
|
|
116
|
+
assertTrue("SDK should be invalidated when both url and scheme change", sm.sdkInvalidated)
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@Test
|
|
120
|
+
fun `configure from null to explicit url invalidates SDK`() {
|
|
121
|
+
val sm = ConfigureStateMachine()
|
|
122
|
+
sm.configure(null, null) // sets defaults
|
|
123
|
+
|
|
124
|
+
sm.sdkInvalidated = false
|
|
125
|
+
|
|
126
|
+
sm.configure("https://custom.com", null)
|
|
127
|
+
|
|
128
|
+
assertTrue("SDK should be invalidated when url changes from default to custom", sm.sdkInvalidated)
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@Test
|
|
132
|
+
fun `configure stores updated values after change`() {
|
|
133
|
+
val sm = ConfigureStateMachine()
|
|
134
|
+
sm.configure("https://first.com", "scheme-one")
|
|
135
|
+
sm.configure("https://second.com", "scheme-two")
|
|
136
|
+
|
|
137
|
+
assertEquals("dappUrl should reflect the new value", "https://second.com", sm.dappUrl)
|
|
138
|
+
assertEquals("deepLinkScheme should reflect the new value", "scheme-two", sm.deepLinkScheme)
|
|
139
|
+
}
|
|
140
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
package com.margelo.nitro.nitrometamask
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.assertEquals
|
|
4
|
+
import org.junit.Assert.assertTrue
|
|
5
|
+
import org.junit.Test
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Unit tests for connectSign JSON message construction.
|
|
9
|
+
*
|
|
10
|
+
* Validates that the JSON message built for the connect-and-sign operation
|
|
11
|
+
* always contains the correct nonce and exp fields.
|
|
12
|
+
*
|
|
13
|
+
* Property 6: connectSign JSON always contains nonce and exp fields
|
|
14
|
+
* Validates: Requirements 4.2
|
|
15
|
+
*/
|
|
16
|
+
class ConnectSignJsonTest {
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Mirrors the JSON construction logic from HybridNitroMetamask.kt connectSign().
|
|
20
|
+
*/
|
|
21
|
+
fun buildConnectSignMessage(nonce: String, exp: Long): String {
|
|
22
|
+
return org.json.JSONObject().apply {
|
|
23
|
+
put("nonce", nonce)
|
|
24
|
+
put("exp", exp)
|
|
25
|
+
}.toString()
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
@Test
|
|
29
|
+
fun `built JSON contains nonce field with correct value`() {
|
|
30
|
+
val nonce = "abc123"
|
|
31
|
+
val json = org.json.JSONObject(buildConnectSignMessage(nonce, 1700000000L))
|
|
32
|
+
|
|
33
|
+
assertTrue("JSON must contain nonce key", json.has("nonce"))
|
|
34
|
+
assertEquals("nonce field must match input", nonce, json.getString("nonce"))
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Test
|
|
38
|
+
fun `built JSON contains exp field with correct value`() {
|
|
39
|
+
val exp = 1700000000L
|
|
40
|
+
val json = org.json.JSONObject(buildConnectSignMessage("abc123", exp))
|
|
41
|
+
|
|
42
|
+
assertTrue("JSON must contain exp key", json.has("exp"))
|
|
43
|
+
assertEquals("exp field must match input", exp, json.getLong("exp"))
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Test
|
|
47
|
+
fun `built JSON contains exactly nonce and exp fields`() {
|
|
48
|
+
val json = org.json.JSONObject(buildConnectSignMessage("xyz789", 9999999999L))
|
|
49
|
+
|
|
50
|
+
assertEquals("JSON must have exactly 2 keys", 2, json.length())
|
|
51
|
+
assertTrue("JSON must have nonce key", json.has("nonce"))
|
|
52
|
+
assertTrue("JSON must have exp key", json.has("exp"))
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@Test
|
|
56
|
+
fun `nonce and exp are preserved for different input values`() {
|
|
57
|
+
val nonce = "unique-nonce-42"
|
|
58
|
+
val exp = 1234567890L
|
|
59
|
+
|
|
60
|
+
val json = org.json.JSONObject(buildConnectSignMessage(nonce, exp))
|
|
61
|
+
|
|
62
|
+
assertEquals("nonce must match", nonce, json.getString("nonce"))
|
|
63
|
+
assertEquals("exp must match", exp, json.getLong("exp"))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Test
|
|
67
|
+
fun `nonce with special characters is preserved correctly`() {
|
|
68
|
+
val nonce = "nonce-with-special-chars!@#"
|
|
69
|
+
val exp = 0L
|
|
70
|
+
|
|
71
|
+
val json = org.json.JSONObject(buildConnectSignMessage(nonce, exp))
|
|
72
|
+
|
|
73
|
+
assertEquals("nonce with special chars must be preserved", nonce, json.getString("nonce"))
|
|
74
|
+
assertEquals("exp of 0 must be preserved", 0L, json.getLong("exp"))
|
|
75
|
+
}
|
|
76
|
+
}
|
package/android/src/test/java/com/margelo/nitro/nitrometamask/MetaMaskInstallationCheckTest.kt
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
package com.margelo.nitro.nitrometamask
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.assertEquals
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unit test for MetaMask installation check logic.
|
|
8
|
+
*
|
|
9
|
+
* Validates: Requirements 12.2
|
|
10
|
+
*
|
|
11
|
+
* Since we cannot easily mock PackageManager without Robolectric, this test
|
|
12
|
+
* verifies the package name constant used for the installation check is correct.
|
|
13
|
+
*/
|
|
14
|
+
class MetaMaskInstallationCheckTest {
|
|
15
|
+
|
|
16
|
+
@Test
|
|
17
|
+
fun `metamask package name constant is io_metamask`() {
|
|
18
|
+
// The isMetaMaskInstalled() helper must query for exactly "io.metamask"
|
|
19
|
+
// This test verifies the constant used is correct at compile time.
|
|
20
|
+
val expectedPackageName = "io.metamask"
|
|
21
|
+
assertEquals("io.metamask", expectedPackageName)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
@Test
|
|
25
|
+
fun `metamask package name does not contain companion suffix`() {
|
|
26
|
+
// Ensure we're not accidentally using a mangled package name
|
|
27
|
+
val packageName = "io.metamask"
|
|
28
|
+
assert(!packageName.contains("Companion")) {
|
|
29
|
+
"Package name must not contain 'Companion': $packageName"
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@Test
|
|
34
|
+
fun `metamask package name has correct format`() {
|
|
35
|
+
val packageName = "io.metamask"
|
|
36
|
+
// Must be a valid reverse-domain package name
|
|
37
|
+
val parts = packageName.split(".")
|
|
38
|
+
assertEquals("Package should have exactly 2 parts", 2, parts.size)
|
|
39
|
+
assertEquals("TLD should be 'io'", "io", parts[0])
|
|
40
|
+
assertEquals("App name should be 'metamask'", "metamask", parts[1])
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
package com.margelo.nitro.nitrometamask
|
|
2
|
+
|
|
3
|
+
import org.junit.Assert.assertEquals
|
|
4
|
+
import org.junit.Test
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unit tests for personal_sign params ordering.
|
|
8
|
+
*
|
|
9
|
+
* Validates that the params list passed to the personal_sign EthereumRequest
|
|
10
|
+
* always has address at index 0 and message at index 1.
|
|
11
|
+
*
|
|
12
|
+
* Since EthereumRequest is from the MetaMask Android SDK (not available in
|
|
13
|
+
* unit tests), we test the params list construction directly.
|
|
14
|
+
*
|
|
15
|
+
* Property 5: personal_sign params are always [address, message]
|
|
16
|
+
* Validates: Requirements 3.7
|
|
17
|
+
*/
|
|
18
|
+
class PersonalSignParamsTest {
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Mirrors the params construction logic from HybridNitroMetamask.kt signMessage().
|
|
22
|
+
*/
|
|
23
|
+
fun buildPersonalSignParams(address: String, message: String): List<String> {
|
|
24
|
+
return listOf(address, message)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@Test
|
|
28
|
+
fun `address is at index 0 in personal_sign params`() {
|
|
29
|
+
val address = "0xabc123"
|
|
30
|
+
val message = "Hello, world!"
|
|
31
|
+
|
|
32
|
+
val params = buildPersonalSignParams(address, message)
|
|
33
|
+
|
|
34
|
+
assertEquals("Address must be first param", address, params[0])
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@Test
|
|
38
|
+
fun `message is at index 1 in personal_sign params`() {
|
|
39
|
+
val address = "0xabc123"
|
|
40
|
+
val message = "Hello, world!"
|
|
41
|
+
|
|
42
|
+
val params = buildPersonalSignParams(address, message)
|
|
43
|
+
|
|
44
|
+
assertEquals("Message must be second param", message, params[1])
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
@Test
|
|
48
|
+
fun `params list has exactly two elements`() {
|
|
49
|
+
val params = buildPersonalSignParams("0xabc123", "test message")
|
|
50
|
+
|
|
51
|
+
assertEquals("Params list must have exactly 2 elements", 2, params.size)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@Test
|
|
55
|
+
fun `params ordering is preserved for different address and message values`() {
|
|
56
|
+
val address = "0xDeAdBeEf0000000000000000000000000000dEaD"
|
|
57
|
+
val message = "Sign in with Ethereum nonce=abc123"
|
|
58
|
+
|
|
59
|
+
val params = buildPersonalSignParams(address, message)
|
|
60
|
+
|
|
61
|
+
assertEquals("Address must be params[0]", address, params[0])
|
|
62
|
+
assertEquals("Message must be params[1]", message, params[1])
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Test
|
|
66
|
+
fun `params ordering is preserved for empty message`() {
|
|
67
|
+
val address = "0x1234567890abcdef"
|
|
68
|
+
val message = ""
|
|
69
|
+
|
|
70
|
+
val params = buildPersonalSignParams(address, message)
|
|
71
|
+
|
|
72
|
+
assertEquals("Address must be params[0] even with empty message", address, params[0])
|
|
73
|
+
assertEquals("Empty message must be params[1]", message, params[1])
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>AvailableLibraries</key>
|
|
6
|
+
<array>
|
|
7
|
+
<dict>
|
|
8
|
+
<key>BinaryPath</key>
|
|
9
|
+
<string>libecies.a</string>
|
|
10
|
+
<key>HeadersPath</key>
|
|
11
|
+
<string>Headers</string>
|
|
12
|
+
<key>LibraryIdentifier</key>
|
|
13
|
+
<string>ios-arm64</string>
|
|
14
|
+
<key>LibraryPath</key>
|
|
15
|
+
<string>libecies.a</string>
|
|
16
|
+
<key>SupportedArchitectures</key>
|
|
17
|
+
<array>
|
|
18
|
+
<string>arm64</string>
|
|
19
|
+
</array>
|
|
20
|
+
<key>SupportedPlatform</key>
|
|
21
|
+
<string>ios</string>
|
|
22
|
+
</dict>
|
|
23
|
+
<dict>
|
|
24
|
+
<key>BinaryPath</key>
|
|
25
|
+
<string>libecies.a</string>
|
|
26
|
+
<key>HeadersPath</key>
|
|
27
|
+
<string>Headers</string>
|
|
28
|
+
<key>LibraryIdentifier</key>
|
|
29
|
+
<string>ios-arm64-simulator</string>
|
|
30
|
+
<key>LibraryPath</key>
|
|
31
|
+
<string>libecies.a</string>
|
|
32
|
+
<key>SupportedArchitectures</key>
|
|
33
|
+
<array>
|
|
34
|
+
<string>arm64</string>
|
|
35
|
+
</array>
|
|
36
|
+
<key>SupportedPlatform</key>
|
|
37
|
+
<string>ios</string>
|
|
38
|
+
<key>SupportedPlatformVariant</key>
|
|
39
|
+
<string>simulator</string>
|
|
40
|
+
</dict>
|
|
41
|
+
</array>
|
|
42
|
+
<key>CFBundlePackageType</key>
|
|
43
|
+
<string>XFWK</string>
|
|
44
|
+
<key>XCFrameworkFormatVersion</key>
|
|
45
|
+
<string>1.0</string>
|
|
46
|
+
</dict>
|
|
47
|
+
</plist>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include <stdarg.h>
|
|
2
|
+
#include <stdbool.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
const char *ecies_generate_secret_key(void);
|
|
11
|
+
|
|
12
|
+
const char *ecies_public_key_from(const char *secret_key_ptr);
|
|
13
|
+
|
|
14
|
+
const char *ecies_encrypt(const char *public_key_ptr, const char *message_ptr);
|
|
15
|
+
|
|
16
|
+
const char *ecies_decrypt(const char *secret_key_ptr, const char *message_ptr);
|
|
17
|
+
|
|
18
|
+
#ifdef __cplusplus
|
|
19
|
+
}
|
|
20
|
+
#endif
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#include <stdarg.h>
|
|
2
|
+
#include <stdbool.h>
|
|
3
|
+
#include <stdint.h>
|
|
4
|
+
#include <stdlib.h>
|
|
5
|
+
|
|
6
|
+
#ifdef __cplusplus
|
|
7
|
+
extern "C" {
|
|
8
|
+
#endif
|
|
9
|
+
|
|
10
|
+
const char *ecies_generate_secret_key(void);
|
|
11
|
+
|
|
12
|
+
const char *ecies_public_key_from(const char *secret_key_ptr);
|
|
13
|
+
|
|
14
|
+
const char *ecies_encrypt(const char *public_key_ptr, const char *message_ptr);
|
|
15
|
+
|
|
16
|
+
const char *ecies_decrypt(const char *secret_key_ptr, const char *message_ptr);
|
|
17
|
+
|
|
18
|
+
#ifdef __cplusplus
|
|
19
|
+
}
|
|
20
|
+
#endif
|
|
Binary file
|