@novastera-oss/nitro-metamask 0.3.3 → 0.4.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/README.md +73 -12
- package/android/src/main/java/com/margelo/nitro/nitrometamask/HybridNitroMetamask.kt +349 -175
- package/app.plugin.js +121 -0
- package/ios/HybridNitroMetamask.swift +71 -110
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts +31 -6
- package/lib/typescript/src/specs/nitro-metamask.nitro.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroMetamask+autolinking.cmake +2 -0
- package/nitrogen/generated/android/c++/JConnectResult.hpp +3 -3
- package/nitrogen/generated/android/c++/JConnectSignResult.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.cpp +48 -7
- package/nitrogen/generated/android/c++/JHybridNitroMetamaskSpec.hpp +4 -2
- package/nitrogen/generated/android/c++/JVariant_NullType_Long.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_Long.hpp +69 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +70 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectResult.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/ConnectSignResult.kt +44 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/HybridNitroMetamaskSpec.kt +11 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_Long.kt +59 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitrometamask/Variant_NullType_String.kt +59 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.cpp +24 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Bridge.hpp +192 -0
- package/nitrogen/generated/ios/NitroMetamask-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/c++/HybridNitroMetamaskSpecSwift.hpp +24 -3
- package/nitrogen/generated/ios/swift/ConnectResult.swift +2 -2
- package/nitrogen/generated/ios/swift/ConnectSignResult.swift +40 -0
- package/nitrogen/generated/ios/swift/Func_void_ConnectSignResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__int64_t_.swift +59 -0
- package/nitrogen/generated/ios/swift/Func_void_std__variant_nitro__NullType__std__string_.swift +59 -0
- package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec.swift +4 -2
- package/nitrogen/generated/ios/swift/HybridNitroMetamaskSpec_cxx.swift +67 -8
- package/nitrogen/generated/ios/swift/Variant_NullType_Int64.swift +18 -0
- package/nitrogen/generated/ios/swift/Variant_NullType_String.swift +18 -0
- package/nitrogen/generated/shared/c++/ConnectResult.hpp +5 -5
- package/nitrogen/generated/shared/c++/ConnectSignResult.hpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroMetamaskSpec.hpp +9 -2
- package/package.json +18 -4
- package/src/specs/nitro-metamask.nitro.ts +32 -6
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @novastera-oss/nitro-metamask
|
|
2
2
|
|
|
3
|
-
Novastera authentication with native mobile libraries
|
|
3
|
+
Novastera authentication with native mobile metamask libraries. Those aims at providing native mobile support for the metamask wallet.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@novastera-oss/nitro-metamask)
|
|
6
6
|
[](https://www.npmjs.com/package/@novastera-oss/nitro-metamask)
|
|
@@ -51,17 +51,61 @@ Add this inside your `MainActivity` `<activity>` tag:
|
|
|
51
51
|
|
|
52
52
|
### iOS Configuration
|
|
53
53
|
|
|
54
|
-
For
|
|
54
|
+
**For Expo projects:** The package includes an Expo config plugin that automatically adds the required AppDelegate code. Just add the plugin to your `app.json` or `app.config.js`:
|
|
55
|
+
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"expo": {
|
|
59
|
+
"plugins": ["@novastera-oss/nitro-metamask"]
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The plugin will automatically:
|
|
65
|
+
- Add the `import MetaMaskSDK` statement
|
|
66
|
+
- Add the `application(_:open:options:)` method to handle MetaMask deep links
|
|
67
|
+
- Work with both Swift and Objective-C AppDelegate files
|
|
68
|
+
|
|
69
|
+
**For bare React Native projects:** Add deep link handling manually in your `AppDelegate.swift` (or `AppDelegate.m` for Objective-C):
|
|
70
|
+
|
|
71
|
+
**File:** `ios/YourAppName/AppDelegate.swift`
|
|
72
|
+
|
|
73
|
+
```swift
|
|
74
|
+
import MetaMaskSDK
|
|
75
|
+
|
|
76
|
+
// ... existing AppDelegate code ...
|
|
77
|
+
|
|
78
|
+
// Handle deep links from MetaMask wallet
|
|
79
|
+
// MetaMask returns to the app via deep link after signing/connecting
|
|
80
|
+
func application(
|
|
81
|
+
_ app: UIApplication,
|
|
82
|
+
open url: URL,
|
|
83
|
+
options: [UIApplication.OpenURLOptionsKey: Any] = [:]
|
|
84
|
+
) -> Bool {
|
|
85
|
+
// Check if this is a MetaMask deep link (host="mmsdk")
|
|
86
|
+
if let components = URLComponents(url: url, resolvingAgainstBaseURL: true),
|
|
87
|
+
components.host == "mmsdk" {
|
|
88
|
+
// Handle MetaMask deep link return
|
|
89
|
+
MetaMaskSDK.shared.handleUrl(url)
|
|
90
|
+
return true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Handle other deep links (e.g., React Native Linking)
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Info.plist:** The URL scheme is automatically detected from your `Info.plist` `CFBundleURLSchemes` configuration. Ensure you have a URL scheme configured (e.g., `nitrometamask`).
|
|
55
99
|
|
|
56
100
|
## Usage
|
|
57
101
|
|
|
58
102
|
```typescript
|
|
59
103
|
import { NitroMetamask } from '@novastera-oss/nitro-metamask';
|
|
60
104
|
|
|
61
|
-
// Optional: Configure dapp URL
|
|
62
|
-
// If not called, defaults to "https://novastera.com"
|
|
105
|
+
// Optional: Configure dapp URL and deep link scheme
|
|
106
|
+
// If not called, defaults to "https://novastera.com" and auto-detects deep link scheme
|
|
63
107
|
// This URL is ONLY used for SDK validation - the deep link return is handled automatically
|
|
64
|
-
NitroMetamask.configure('https://yourdomain.com'); // Optional
|
|
108
|
+
NitroMetamask.configure('https://yourdomain.com', 'nitrometamask'); // Optional
|
|
65
109
|
|
|
66
110
|
// Connect to MetaMask
|
|
67
111
|
const connectResult = await NitroMetamask.connect();
|
|
@@ -71,10 +115,18 @@ console.log('Connected:', connectResult.address, 'Chain:', connectResult.chainId
|
|
|
71
115
|
const signature = await NitroMetamask.signMessage('Hello from my app!');
|
|
72
116
|
|
|
73
117
|
// Connect and sign in one call (convenience method)
|
|
74
|
-
// This constructs a JSON message with
|
|
118
|
+
// This constructs a JSON message with nonce and exp, then signs it
|
|
119
|
+
// Returns signature, address, and chainId together
|
|
75
120
|
const nonce = 'random-nonce-123';
|
|
76
121
|
const exp = BigInt(Date.now() + 42000); // 42 seconds from now (use BigInt for timestamp)
|
|
77
|
-
const
|
|
122
|
+
const result = await NitroMetamask.connectSign(nonce, exp);
|
|
123
|
+
console.log('Signature:', result.signature);
|
|
124
|
+
console.log('Address:', result.address);
|
|
125
|
+
console.log('Chain ID:', result.chainId);
|
|
126
|
+
|
|
127
|
+
// Get current address and chainId (useful if you need to check after other operations)
|
|
128
|
+
const address = await NitroMetamask.getAddress();
|
|
129
|
+
const chainId = await NitroMetamask.getChainId();
|
|
78
130
|
```
|
|
79
131
|
|
|
80
132
|
### How Deep Linking Works
|
|
@@ -89,20 +141,29 @@ const signature = await NitroMetamask.connectSign(nonce, exp);
|
|
|
89
141
|
- If you don't have a website, the default works fine - it's just for validation
|
|
90
142
|
- [Reference](https://raw.githubusercontent.com/MetaMask/metamask-android-sdk/a448378fbedc3afbf70759ba71294f7819af2f37/metamask-android-sdk/src/main/java/io/metamask/androidsdk/DappMetadata.kt)
|
|
91
143
|
|
|
92
|
-
2. **Deep Link Return** (automatic):
|
|
144
|
+
2. **Deep Link Return** (automatic or configurable):
|
|
93
145
|
- Automatically detected from your `AndroidManifest.xml` intent filter
|
|
94
146
|
- The SDK reads `<data android:scheme="..." android:host="mmsdk" />` and uses it to return to your app
|
|
147
|
+
- You can also explicitly provide the scheme via `configure()`: `NitroMetamask.configure('https://yourdomain.com', 'nitrometamask')`
|
|
95
148
|
- This is what actually makes MetaMask return to your app after operations
|
|
96
|
-
-
|
|
149
|
+
- If not explicitly configured, the library will attempt to auto-detect it from your manifest
|
|
97
150
|
|
|
98
151
|
**Summary:**
|
|
99
152
|
- The `configure()` URL is just for SDK validation (you can use the default if you don't have a website)
|
|
100
|
-
- The deep link
|
|
153
|
+
- The deep link scheme can be auto-detected or explicitly provided via `configure()`
|
|
101
154
|
- Your app will return correctly as long as the manifest is configured properly
|
|
102
155
|
|
|
103
|
-
##
|
|
156
|
+
## About Novastera
|
|
157
|
+
|
|
158
|
+
[Novastera](https://novastera.com) is a modern CRM and ERP platform designed to streamline business operations and customer relationship management. This library is part of Novastera's open-source ecosystem, providing native mobile MetaMask wallet integration for React Native applications.
|
|
159
|
+
|
|
160
|
+
**Key Features:**
|
|
161
|
+
- Native mobile MetaMask wallet support for iOS and Android
|
|
162
|
+
- Seamless deep linking integration
|
|
163
|
+
- Secure authentication and message signing
|
|
164
|
+
- Built with [Nitro Modules](https://nitro.margelo.com) for optimal performance
|
|
104
165
|
|
|
105
|
-
|
|
166
|
+
Learn more at [novastera.com](https://novastera.com)
|
|
106
167
|
|
|
107
168
|
## Contributing
|
|
108
169
|
|