-
Notifications
You must be signed in to change notification settings - Fork 2.2k
feat(rtn-passkeys): scaffold native package - 1 #14390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jjarvisp
wants to merge
1
commit into
feat/rtn-passkeys/main
Choose a base branch
from
feat/rtn-passkeys/1-add-new-package
base: feat/rtn-passkeys/main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
require "json" | ||
|
||
package = JSON.parse(File.read(File.join(__dir__, "package.json"))) | ||
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32' | ||
|
||
Pod::Spec.new do |s| | ||
s.name = "AmplifyRtnPasskeys" | ||
s.version = package["version"] | ||
s.summary = package["description"] | ||
s.homepage = package["homepage"] | ||
s.license = package["license"] | ||
s.authors = package["author"] | ||
|
||
s.platforms = { :ios => '15.1' } | ||
s.source = { :git => "https://github.com/aws-amplify/amplify-js.git", :tag => "#{s.version}" } | ||
|
||
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}" | ||
s.exclude_files = [ 'ios/tests' ] | ||
s.private_header_files = "ios/generated/**/*.h" | ||
|
||
install_modules_dependencies(s) | ||
|
||
s.test_spec 'tests' do |test_spec| | ||
test_spec.source_files = 'ios/tests/*.swift' | ||
test_spec.frameworks ='XCTest' | ||
end | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
buildscript { | ||
ext.getExtOrDefault = { name -> | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AmplifyRtnPasskeys_' + name] | ||
} | ||
|
||
repositories { | ||
google() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
classpath "com.android.tools.build:gradle:8.7.3" | ||
// noinspection DifferentKotlinGradleVersion | ||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}" | ||
} | ||
} | ||
|
||
|
||
apply plugin: "com.android.library" | ||
apply plugin: "kotlin-android" | ||
apply plugin: "com.facebook.react" | ||
|
||
def getExtOrIntegerDefault(name) { | ||
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AmplifyRtnPasskeys_" + name]).toInteger() | ||
} | ||
|
||
|
||
android { | ||
namespace "com.amazonaws.amplify.rtnpasskeys" | ||
|
||
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion") | ||
|
||
defaultConfig { | ||
minSdkVersion getExtOrIntegerDefault("minSdkVersion") | ||
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion") | ||
} | ||
|
||
buildFeatures { | ||
buildConfig true | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
} | ||
} | ||
|
||
lintOptions { | ||
disable "GradleCompatible" | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java.srcDirs += [ | ||
"generated/java", | ||
"generated/jni" | ||
] | ||
} | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
google() | ||
} | ||
|
||
def kotlin_version = getExtOrDefault("kotlinVersion") | ||
|
||
dependencies { | ||
implementation "com.facebook.react:react-android" | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" | ||
|
||
implementation "androidx.credentials:credentials:1.5.0" | ||
implementation "androidx.credentials:credentials-play-services-auth:1.5.0" | ||
|
||
testImplementation "junit:junit:4.13.2" | ||
testImplementation "org.robolectric:robolectric:4.14.1" | ||
testImplementation "io.mockk:mockk:1.14.2" | ||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2" | ||
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2" | ||
Comment on lines
+78
to
+85
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are manual changes required to support webauthn and enable unit testing. |
||
} | ||
|
||
react { | ||
jsRootDir = file("../src/") | ||
libraryName = "AmplifyRtnPasskeys" | ||
codegenJavaPackageName = "com.amazonaws.amplify.rtnpasskeys" | ||
} |
47 changes: 47 additions & 0 deletions
47
...skeys/android/generated/java/com/facebook/fbreact/specs/NativeAmplifyRtnPasskeysSpec.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GenerateModuleJavaSpec.js | ||
* | ||
* @nolint | ||
*/ | ||
|
||
package com.facebook.fbreact.specs; | ||
|
||
import com.facebook.proguard.annotations.DoNotStrip; | ||
import com.facebook.react.bridge.Promise; | ||
import com.facebook.react.bridge.ReactApplicationContext; | ||
import com.facebook.react.bridge.ReactContextBaseJavaModule; | ||
import com.facebook.react.bridge.ReactMethod; | ||
import com.facebook.react.bridge.ReadableMap; | ||
import com.facebook.react.turbomodule.core.interfaces.TurboModule; | ||
import javax.annotation.Nonnull; | ||
|
||
public abstract class NativeAmplifyRtnPasskeysSpec extends ReactContextBaseJavaModule implements TurboModule { | ||
public static final String NAME = "AmplifyRtnPasskeys"; | ||
|
||
public NativeAmplifyRtnPasskeysSpec(ReactApplicationContext reactContext) { | ||
super(reactContext); | ||
} | ||
|
||
@Override | ||
public @Nonnull String getName() { | ||
return NAME; | ||
} | ||
|
||
@ReactMethod(isBlockingSynchronousMethod = true) | ||
@DoNotStrip | ||
public abstract boolean getIsPasskeySupported(); | ||
|
||
@ReactMethod | ||
@DoNotStrip | ||
public abstract void createPasskey(ReadableMap input, Promise promise); | ||
|
||
@ReactMethod | ||
@DoNotStrip | ||
public abstract void getPasskey(ReadableMap input, Promise promise); | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/rtn-passkeys/android/generated/jni/AmplifyRtnPasskeysSpec-generated.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GenerateModuleJniCpp.js | ||
*/ | ||
|
||
#include "AmplifyRtnPasskeysSpec.h" | ||
|
||
namespace facebook::react { | ||
|
||
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getIsPasskeySupported(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { | ||
static jmethodID cachedMethodId = nullptr; | ||
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "getIsPasskeySupported", "()Z", args, count, cachedMethodId); | ||
} | ||
|
||
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_createPasskey(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { | ||
static jmethodID cachedMethodId = nullptr; | ||
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "createPasskey", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId); | ||
} | ||
|
||
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getPasskey(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) { | ||
static jmethodID cachedMethodId = nullptr; | ||
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getPasskey", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId); | ||
} | ||
|
||
NativeAmplifyRtnPasskeysSpecJSI::NativeAmplifyRtnPasskeysSpecJSI(const JavaTurboModule::InitParams ¶ms) | ||
: JavaTurboModule(params) { | ||
methodMap_["getIsPasskeySupported"] = MethodMetadata {0, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getIsPasskeySupported}; | ||
methodMap_["createPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_createPasskey}; | ||
methodMap_["getPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getPasskey}; | ||
} | ||
|
||
std::shared_ptr<TurboModule> AmplifyRtnPasskeysSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms) { | ||
if (moduleName == "AmplifyRtnPasskeys") { | ||
return std::make_shared<NativeAmplifyRtnPasskeysSpecJSI>(params); | ||
} | ||
return nullptr; | ||
} | ||
|
||
} // namespace facebook::react |
31 changes: 31 additions & 0 deletions
31
packages/rtn-passkeys/android/generated/jni/AmplifyRtnPasskeysSpec.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GenerateModuleJniH.js | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <ReactCommon/JavaTurboModule.h> | ||
#include <ReactCommon/TurboModule.h> | ||
#include <jsi/jsi.h> | ||
|
||
namespace facebook::react { | ||
|
||
/** | ||
* JNI C++ class for module 'NativeAmplifyRtnPasskeys' | ||
*/ | ||
class JSI_EXPORT NativeAmplifyRtnPasskeysSpecJSI : public JavaTurboModule { | ||
public: | ||
NativeAmplifyRtnPasskeysSpecJSI(const JavaTurboModule::InitParams ¶ms); | ||
}; | ||
|
||
|
||
JSI_EXPORT | ||
std::shared_ptr<TurboModule> AmplifyRtnPasskeysSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams ¶ms); | ||
|
||
} // namespace facebook::react |
36 changes: 36 additions & 0 deletions
36
packages/rtn-passkeys/android/generated/jni/CMakeLists.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) Meta Platforms, Inc. and affiliates. | ||
# | ||
# This source code is licensed under the MIT license found in the | ||
# LICENSE file in the root directory of this source tree. | ||
|
||
cmake_minimum_required(VERSION 3.13) | ||
set(CMAKE_VERBOSE_MAKEFILE on) | ||
|
||
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/AmplifyRtnPasskeysSpec/*.cpp) | ||
|
||
add_library( | ||
react_codegen_AmplifyRtnPasskeysSpec | ||
OBJECT | ||
${react_codegen_SRCS} | ||
) | ||
|
||
target_include_directories(react_codegen_AmplifyRtnPasskeysSpec PUBLIC . react/renderer/components/AmplifyRtnPasskeysSpec) | ||
|
||
target_link_libraries( | ||
react_codegen_AmplifyRtnPasskeysSpec | ||
fbjni | ||
jsi | ||
# We need to link different libraries based on whether we are building rncore or not, that's necessary | ||
# because we want to break a circular dependency between react_codegen_rncore and reactnative | ||
reactnative | ||
) | ||
|
||
target_compile_options( | ||
react_codegen_AmplifyRtnPasskeysSpec | ||
PRIVATE | ||
-DLOG_TAG=\"ReactNative\" | ||
-fexceptions | ||
-frtti | ||
-std=c++20 | ||
-Wall | ||
) |
40 changes: 40 additions & 0 deletions
40
.../react/renderer/components/AmplifyRtnPasskeysSpec/AmplifyRtnPasskeysSpecJSI-generated.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen). | ||
* | ||
* Do not edit this file as changes may cause incorrect behavior and will be lost | ||
* once the code is regenerated. | ||
* | ||
* @generated by codegen project: GenerateModuleCpp.js | ||
*/ | ||
|
||
#include "AmplifyRtnPasskeysSpecJSI.h" | ||
|
||
namespace facebook::react { | ||
|
||
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getIsPasskeySupported(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { | ||
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->getIsPasskeySupported( | ||
rt | ||
); | ||
} | ||
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_createPasskey(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { | ||
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->createPasskey( | ||
rt, | ||
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt) | ||
); | ||
} | ||
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getPasskey(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) { | ||
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->getPasskey( | ||
rt, | ||
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt) | ||
); | ||
} | ||
|
||
NativeAmplifyRtnPasskeysCxxSpecJSI::NativeAmplifyRtnPasskeysCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker) | ||
: TurboModule("AmplifyRtnPasskeys", jsInvoker) { | ||
methodMap_["getIsPasskeySupported"] = MethodMetadata {0, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getIsPasskeySupported}; | ||
methodMap_["createPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_createPasskey}; | ||
methodMap_["getPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getPasskey}; | ||
} | ||
|
||
|
||
} // namespace facebook::react |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe minor but the gradle version seems to be newer than other RTN packages in the repo, which is "8.0.2"