Skip to content

Commit

Permalink
chore: rename wallet-sdk to mobile-sdk (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
sbihel authored Aug 2, 2024
1 parent db6a701 commit 8967ec7
Show file tree
Hide file tree
Showing 46 changed files with 378 additions and 364 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,5 @@ lib/

# typedoc
docs/

example/android/app/release/
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ The [example app](/example/) demonstrates usage of the library. You need to run

It is configured to use the local version of the library, so any changes you make to the library's source code will be reflected in the example app. Changes to the library's JavaScript code will be reflected in the example app without a rebuild, but native code changes will require a rebuild of the example app.

If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/WalletSdkExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-wallet-sdk`.
If you want to use Android Studio or XCode to edit the native code, you can open the `example/android` or `example/ios` directories respectively in those editors. To edit the Objective-C or Swift files, open `example/ios/MobileSdkExample.xcworkspace` in XCode and find the source files at `Pods > Development Pods > react-native-mobile-sdk`.

To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-wallet-sdk` under `Android`.
To edit the Java or Kotlin files, open `example/android` in Android studio and find the source files at `react-native-mobile-sdk` under `Android`.

You can use various commands from the root directory to work with the project.

Expand Down Expand Up @@ -71,7 +71,7 @@ yarn clean
To confirm that the app is running with the new architecture, you can check the Metro logs for a message like this:

```sh
Running "WalletSdkExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
Running "MobileSdkExample" with {"fabric":true,"initialProps":{"concurrentRoot":true},"rootTag":1}
```

Note the `"fabric":true` and `"concurrentRoot":true` properties.
Expand Down
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[![NPM Version](https://img.shields.io/npm/v/%40spruceid%2Freact-native-wallet-sdk)](https://www.npmjs.com/package/@spruceid/react-native-wallet-sdk)
[![ghpages](https://img.shields.io/badge/docs-passing-green)](https://spruceid.github.io/wallet-sdk-react/)
[![NPM Version](https://img.shields.io/npm/v/%40spruceid%2Freact-native-mobile-sdk)](https://www.npmjs.com/package/@spruceid/react-native-mobile-sdk)
[![ghpages](https://img.shields.io/badge/docs-passing-green)](https://spruceid.github.io/mobile-sdk-react/)

# SpruceID Wallet SDK for React Native
# SpruceID Mobile SDK for React Native

## Maturity Disclaimer

In its current version, Wallet SDK has not yet undergone a formal security audit
In its current version, Mobile SDK has not yet undergone a formal security audit
to desired levels of confidence for suitable use in production systems. This
implementation is currently suitable for exploratory work and experimentation
only. We welcome feedback on the usability, architecture, and security of this
Expand All @@ -15,7 +15,7 @@ security firm before the v1.0 release.
## Installation

```sh
npm install @spruceid/react-native-wallet-sdk
npm install @spruceid/react-native-mobile-sdk
```

### iOS
Expand Down Expand Up @@ -54,23 +54,23 @@ await PermissionsAndroid.requestMultiple([
## Usage

```js
import { createMdocFromCbor } from '@spruceid/react-native-wallet-sdk';
import { createMdocFromCbor } from '@spruceid/react-native-mobile-sdk';

// ...

const mdoc = await createMdocFromCbor(mdocCborBase64);
```

For more, see [the documentation](https://spruceid.github.io/wallet-sdk-react/).
For more, see [the documentation](https://spruceid.github.io/mobile-sdk-react/).

## Contributing

See the [contributing guide](https://github.com/spruceid/wallet-sdk-react/blob/main/CONTRIBUTING.md)
See the [contributing guide](https://github.com/spruceid/mobile-sdk-react/blob/main/CONTRIBUTING.md)
to learn how to contribute to the repository and the development workflow.

## Architecture

Our Wallet SDKs use shared code, with most of the logic being written once in
Our Mobile SDKs use shared code, with most of the logic being written once in
Rust, and when not possible, native APIs (e.g. Bluetooth, OS Keychain) are
called in native SDKs.

Expand All @@ -89,6 +89,6 @@ called in native SDKs.
│Rust│
└────┘
```
- [Kotlin SDK](https://github.com/spruceid/wallet-sdk-kt)
- [Swift SDK](https://github.com/spruceid/wallet-sdk-swift)
- [Rust layer](https://github.com/spruceid/wallet-sdk-rs)
- [Kotlin SDK](https://github.com/spruceid/mobile-sdk-kt)
- [Swift SDK](https://github.com/spruceid/mobile-sdk-swift)
- [Rust layer](https://github.com/spruceid/mobile-sdk-rs)
14 changes: 7 additions & 7 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
// Buildscript is evaluated before everything else so we can't use getExtOrDefault
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["WalletSdk_kotlinVersion"]
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["MobileSdk_kotlinVersion"]

repositories {
google()
Expand All @@ -26,11 +26,11 @@ if (isNewArchitectureEnabled()) {
}

def getExtOrDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["WalletSdk_" + name]
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["MobileSdk_" + name]
}

def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["WalletSdk_" + name]).toInteger()
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["MobileSdk_" + name]).toInteger()
}

def supportsNamespace() {
Expand All @@ -44,7 +44,7 @@ def supportsNamespace() {

android {
if (supportsNamespace()) {
namespace "com.walletsdk"
namespace "com.mobilesdk"

sourceSets {
main {
Expand Down Expand Up @@ -109,13 +109,13 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-android:+"
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'com.spruceid.wallet.sdk:walletsdk:0.0.6'
implementation 'com.spruceid.mobile.sdk:mobilesdk:0.0.10'
}

if (isNewArchitectureEnabled()) {
react {
jsRootDir = file("../src/")
libraryName = "WalletSdk"
codegenJavaPackageName = "com.walletsdk"
libraryName = "MobileSdk"
codegenJavaPackageName = "com.mobilesdk"
}
}
10 changes: 5 additions & 5 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
WalletSdk_kotlinVersion=1.7.0
WalletSdk_minSdkVersion=26
WalletSdk_targetSdkVersion=31
WalletSdk_compileSdkVersion=31
WalletSdk_ndkversion=21.4.7075529
MobileSdk_kotlinVersion=1.7.0
MobileSdk_minSdkVersion=26
MobileSdk_targetSdkVersion=31
MobileSdk_compileSdkVersion=31
MobileSdk_ndkversion=21.4.7075529
2 changes: 1 addition & 1 deletion android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.walletsdk">
package="com.mobilesdk">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.walletsdk
package com.mobilesdk

import android.os.Bundle
import androidx.annotation.CallSuper
import androidx.lifecycle.ViewModelProvider
import com.facebook.react.ReactActivity
import com.spruceid.wallet.sdk.CredentialsViewModel
import com.spruceid.mobile.sdk.CredentialsViewModel


/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walletsdk
package com.mobilesdk

import android.util.Log
import com.facebook.react.bridge.Promise
Expand All @@ -10,12 +10,12 @@ import com.facebook.react.bridge.WritableArray
import com.facebook.react.bridge.WritableMap
import com.facebook.react.bridge.WritableNativeArray
import com.facebook.react.bridge.WritableNativeMap
import com.spruceid.wallet.sdk.BLESessionManager
import com.spruceid.wallet.sdk.BLESessionStateDelegate
import com.spruceid.wallet.sdk.CredentialsViewModel
import com.spruceid.wallet.sdk.MDoc
import com.spruceid.wallet.sdk.getBluetoothManager
import com.spruceid.wallet.sdk.rs.ItemsRequest
import com.spruceid.mobile.sdk.BLESessionManager
import com.spruceid.mobile.sdk.BLESessionStateDelegate
import com.spruceid.mobile.sdk.CredentialsViewModel
import com.spruceid.mobile.sdk.MDoc
import com.spruceid.mobile.sdk.getBluetoothManager
import com.spruceid.mobile.sdk.rs.ItemsRequest
import java.security.KeyFactory
import java.security.KeyStore
import java.security.cert.Certificate
Expand All @@ -24,7 +24,7 @@ import java.security.spec.PKCS8EncodedKeySpec

class BleStateCallback(private val context: ReactApplicationContext) : BLESessionStateDelegate() {
override fun update(state: Map<String, Any>) {
Log.i("WalletSdk", state.toString())
Log.i("MobileSdk", state.toString())
val eventName = state.keys.first()
var emitEvent = ""
val eventValue: WritableMap = WritableNativeMap()
Expand Down Expand Up @@ -87,13 +87,13 @@ class BleStateCallback(private val context: ReactApplicationContext) : BLESessio
emitEvent = "onBleSessionSuccess"
}
}
Log.i("WalletSdkModule.BleStateCallback.update", "event: { $emitEvent: $eventValue }")
Log.i("MobileSdkModule.BleStateCallback.update", "event: { $emitEvent: $eventValue }")
context.emitDeviceEvent(emitEvent, eventValue)
}
}

class WalletSdkModule internal constructor(context: ReactApplicationContext) :
WalletSdkSpec(context) {
class MobileSdkModule internal constructor(context: ReactApplicationContext) :
MobileSdkSpec(context) {

private var bleSessionManager: BLESessionManager? = null

Expand Down Expand Up @@ -155,7 +155,7 @@ class WalletSdkModule internal constructor(context: ReactApplicationContext) :
android.util.Base64.decode(cborMdoc.toByteArray(), android.util.Base64.DEFAULT),
"mdoc_key"
)
viewModel.storeCredental(mdoc)
viewModel.storeCredential(mdoc)

val eventValue: WritableMap = WritableNativeMap()
eventValue.putString("id", mdoc.inner.id())
Expand All @@ -177,13 +177,13 @@ class WalletSdkModule internal constructor(context: ReactApplicationContext) :
promise: Promise
) {
val context = this.reactApplicationContext
Log.i("WalletSdk", "ble session start present mdoc")
Log.i("MobileSdk", "ble session start present mdoc")
this.bleSessionManager = BLESessionManager(
viewModel.credentials.value.first() as MDoc,
getBluetoothManager(this.reactApplicationContext)!!,
BleStateCallback(context)
)
Log.i("WalletSdk", "ble manager created")
Log.i("MobileSdk", "ble manager created")
promise.resolve(null)
}

Expand Down Expand Up @@ -223,6 +223,6 @@ class WalletSdkModule internal constructor(context: ReactApplicationContext) :
}

companion object {
const val NAME = "WalletSdk"
const val NAME = "MobileSdk"
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walletsdk
package com.mobilesdk

import com.facebook.react.TurboReactPackage
import com.facebook.react.bridge.ReactApplicationContext
Expand All @@ -7,10 +7,10 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
import com.facebook.react.module.model.ReactModuleInfo
import java.util.HashMap

class WalletSdkPackage : TurboReactPackage() {
class MobileSdkPackage : TurboReactPackage() {
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
return if (name == WalletSdkModule.NAME) {
WalletSdkModule(reactContext)
return if (name == MobileSdkModule.NAME) {
MobileSdkModule(reactContext)
} else {
null
}
Expand All @@ -20,9 +20,9 @@ class WalletSdkPackage : TurboReactPackage() {
return ReactModuleInfoProvider {
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
moduleInfos[WalletSdkModule.NAME] = ReactModuleInfo(
WalletSdkModule.NAME,
WalletSdkModule.NAME,
moduleInfos[MobileSdkModule.NAME] = ReactModuleInfo(
MobileSdkModule.NAME,
MobileSdkModule.NAME,
false, // canOverrideExistingModule
false, // needsEagerInit
true, // hasConstants
Expand Down
7 changes: 7 additions & 0 deletions android/src/newarch/MobileSdkSpec.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.mobilesdk

import com.facebook.react.bridge.ReactApplicationContext

abstract class MobileSdkSpec internal constructor(context: ReactApplicationContext) :
NativeMobileSdkSpec(context) {
}
7 changes: 0 additions & 7 deletions android/src/newarch/WalletSdkSpec.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package com.walletsdk
package com.mobilesdk

import com.facebook.react.bridge.ReactApplicationContext
import com.facebook.react.bridge.ReactContextBaseJavaModule
import com.facebook.react.bridge.Promise
import com.facebook.react.bridge.ReadableArray

abstract class WalletSdkSpec internal constructor(context: ReactApplicationContext) :
abstract class MobileSdkSpec internal constructor(context: ReactApplicationContext) :
ReactContextBaseJavaModule(context) {

abstract fun createSoftPrivateKeyFromPKCS8PEM(_algo: String, key: String, cert: String, promise: Promise)
Expand Down
4 changes: 2 additions & 2 deletions example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ android {
buildToolsVersion rootProject.ext.buildToolsVersion
compileSdk rootProject.ext.compileSdkVersion

namespace "com.walletsdkexample"
namespace "com.mobilesdkexample"
defaultConfig {
applicationId "com.walletsdkexample"
applicationId "com.mobilesdkexample"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walletsdkexample
package com.mobilesdkexample

import com.facebook.react.ReactActivity
import com.facebook.react.ReactActivityDelegate
Expand All @@ -11,7 +11,7 @@ class MainActivity : ReactActivity() {
* Returns the name of the main component registered from JavaScript. This is used to schedule
* rendering of the component.
*/
override fun getMainComponentName(): String = "WalletSdkExample"
override fun getMainComponentName(): String = "MobileSdkExample"

/**
* Returns the instance of the [ReactActivityDelegate]. We use [DefaultReactActivityDelegate]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.walletsdkexample
package com.mobilesdkexample

import android.app.Application
import com.facebook.react.PackageList
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<resources>
<string name="app_name">WalletSdkExample</string>
<string name="app_name">MobileSdkExample</string>
</resources>
2 changes: 1 addition & 1 deletion example/android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
rootProject.name = 'WalletSdkExample'
rootProject.name = 'MobileSdkExample'
apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
include ':app'
includeBuild('../node_modules/@react-native/gradle-plugin')
4 changes: 2 additions & 2 deletions example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "WalletSdkExample",
"displayName": "WalletSdkExample"
"name": "MobileSdkExample",
"displayName": "MobileSdkExample"
}
2 changes: 1 addition & 1 deletion example/index.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8967ec7

Please sign in to comment.