Skip to content

Commit c3efbfc

Browse files
committed
feat: add rtn-passkeys package
1 parent 2f5cdf6 commit c3efbfc

File tree

84 files changed

+6635
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+6635
-29
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ xcuserdata/
5050
!*.xcworkspace/contents.xcworkspacedata
5151
/*.gcno
5252
**/xcshareddata/WorkspaceSettings.xcsettings
53-
**/.xcode.env.local
53+
*.xcode.env.local
5454

5555
### Coverage ###
5656
coverage/
@@ -65,7 +65,12 @@ coverage-ts/
6565
**/example/ios/Podfile.lock
6666
**/example/.bundle
6767
**/example/yarn.lock
68+
**/example/amplify_outputs.json
6869

6970
# rollup
7071
**/.rollup.cache
7172
**/buildMeta
73+
74+
# ruby
75+
vendor/
76+
Gemfile.lock

eslint.config.mjs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ export default [
301301
'**/__tests__/**',
302302
'**/packages/adapter-nextjs/**',
303303
'**/packages/react-native/example/**',
304+
'**/packages/rtn-passkeys/example/**',
304305
],
305306
rules: {
306307
'import/no-extraneous-dependencies': 'error',

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
"packages/rtn-web-browser",
5959
"packages/react-native",
6060
"packages/react-native/example",
61+
"packages/rtn-passkeys",
62+
"packages/rtn-passkeys/example",
6163
"scripts/tsc-compliance-test"
6264
],
6365
"nohoist": [
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
require "json"
5+
6+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
7+
folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
8+
9+
Pod::Spec.new do |s|
10+
s.name = "AmplifyRtnPasskeys"
11+
s.version = package["version"]
12+
s.summary = package["description"]
13+
s.homepage = package["homepage"]
14+
s.license = package["license"]
15+
s.authors = package["author"]
16+
17+
s.platforms = { :ios => '15.1' }
18+
s.source = { :git => "https://github.com/aws-amplify/amplify-js.git", :tag => "#{s.version}" }
19+
20+
s.source_files = "ios/**/*.{h,m,mm,cpp,swift}"
21+
s.exclude_files = [ 'ios/tests' ]
22+
s.private_header_files = "ios/generated/**/*.h"
23+
24+
install_modules_dependencies(s)
25+
26+
s.test_spec 'tests' do |test_spec|
27+
test_spec.source_files = 'ios/tests/*.swift'
28+
test_spec.frameworks ='XCTest'
29+
end
30+
end
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
buildscript {
2+
ext.getExtOrDefault = { name ->
3+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['AmplifyRtnPasskeys_' + name]
4+
}
5+
6+
repositories {
7+
google()
8+
mavenCentral()
9+
}
10+
11+
dependencies {
12+
classpath "com.android.tools.build:gradle:8.7.3"
13+
// noinspection DifferentKotlinGradleVersion
14+
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15+
}
16+
}
17+
18+
19+
apply plugin: "com.android.library"
20+
apply plugin: "kotlin-android"
21+
apply plugin: "com.facebook.react"
22+
23+
def getExtOrIntegerDefault(name) {
24+
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["AmplifyRtnPasskeys_" + name]).toInteger()
25+
}
26+
27+
28+
android {
29+
namespace "com.amazonaws.amplify.rtnpasskeys"
30+
31+
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
32+
33+
defaultConfig {
34+
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
35+
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
36+
}
37+
38+
buildFeatures {
39+
buildConfig true
40+
}
41+
42+
buildTypes {
43+
release {
44+
minifyEnabled false
45+
}
46+
}
47+
48+
lintOptions {
49+
disable "GradleCompatible"
50+
}
51+
52+
compileOptions {
53+
sourceCompatibility JavaVersion.VERSION_1_8
54+
targetCompatibility JavaVersion.VERSION_1_8
55+
}
56+
57+
sourceSets {
58+
main {
59+
java.srcDirs += [
60+
"generated/java",
61+
"generated/jni"
62+
]
63+
}
64+
}
65+
}
66+
67+
repositories {
68+
mavenCentral()
69+
google()
70+
}
71+
72+
def kotlin_version = getExtOrDefault("kotlinVersion")
73+
74+
dependencies {
75+
implementation "com.facebook.react:react-android"
76+
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77+
78+
implementation "androidx.credentials:credentials:1.5.0"
79+
implementation "androidx.credentials:credentials-play-services-auth:1.5.0"
80+
81+
testImplementation "junit:junit:4.13.2"
82+
testImplementation "org.robolectric:robolectric:4.14.1"
83+
testImplementation "io.mockk:mockk:1.14.2"
84+
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2"
85+
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2"
86+
}
87+
88+
react {
89+
jsRootDir = file("../src/")
90+
libraryName = "AmplifyRtnPasskeys"
91+
codegenJavaPackageName = "com.amazonaws.amplify.rtnpasskeys"
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateModuleJavaSpec.js
9+
*
10+
* @nolint
11+
*/
12+
13+
package com.facebook.fbreact.specs;
14+
15+
import com.facebook.proguard.annotations.DoNotStrip;
16+
import com.facebook.react.bridge.Promise;
17+
import com.facebook.react.bridge.ReactApplicationContext;
18+
import com.facebook.react.bridge.ReactContextBaseJavaModule;
19+
import com.facebook.react.bridge.ReactMethod;
20+
import com.facebook.react.bridge.ReadableMap;
21+
import com.facebook.react.turbomodule.core.interfaces.TurboModule;
22+
import javax.annotation.Nonnull;
23+
24+
public abstract class NativeAmplifyRtnPasskeysSpec extends ReactContextBaseJavaModule implements TurboModule {
25+
public static final String NAME = "AmplifyRtnPasskeys";
26+
27+
public NativeAmplifyRtnPasskeysSpec(ReactApplicationContext reactContext) {
28+
super(reactContext);
29+
}
30+
31+
@Override
32+
public @Nonnull String getName() {
33+
return NAME;
34+
}
35+
36+
@ReactMethod(isBlockingSynchronousMethod = true)
37+
@DoNotStrip
38+
public abstract boolean getIsPasskeySupported();
39+
40+
@ReactMethod
41+
@DoNotStrip
42+
public abstract void createPasskey(ReadableMap input, Promise promise);
43+
44+
@ReactMethod
45+
@DoNotStrip
46+
public abstract void getPasskey(ReadableMap input, Promise promise);
47+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateModuleJniCpp.js
9+
*/
10+
11+
#include "AmplifyRtnPasskeysSpec.h"
12+
13+
namespace facebook::react {
14+
15+
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getIsPasskeySupported(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
16+
static jmethodID cachedMethodId = nullptr;
17+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, BooleanKind, "getIsPasskeySupported", "()Z", args, count, cachedMethodId);
18+
}
19+
20+
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_createPasskey(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
21+
static jmethodID cachedMethodId = nullptr;
22+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "createPasskey", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
23+
}
24+
25+
static facebook::jsi::Value __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getPasskey(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
26+
static jmethodID cachedMethodId = nullptr;
27+
return static_cast<JavaTurboModule &>(turboModule).invokeJavaMethod(rt, PromiseKind, "getPasskey", "(Lcom/facebook/react/bridge/ReadableMap;Lcom/facebook/react/bridge/Promise;)V", args, count, cachedMethodId);
28+
}
29+
30+
NativeAmplifyRtnPasskeysSpecJSI::NativeAmplifyRtnPasskeysSpecJSI(const JavaTurboModule::InitParams &params)
31+
: JavaTurboModule(params) {
32+
methodMap_["getIsPasskeySupported"] = MethodMetadata {0, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getIsPasskeySupported};
33+
methodMap_["createPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_createPasskey};
34+
methodMap_["getPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysSpecJSI_getPasskey};
35+
}
36+
37+
std::shared_ptr<TurboModule> AmplifyRtnPasskeysSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params) {
38+
if (moduleName == "AmplifyRtnPasskeys") {
39+
return std::make_shared<NativeAmplifyRtnPasskeysSpecJSI>(params);
40+
}
41+
return nullptr;
42+
}
43+
44+
} // namespace facebook::react
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
/**
3+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4+
*
5+
* Do not edit this file as changes may cause incorrect behavior and will be lost
6+
* once the code is regenerated.
7+
*
8+
* @generated by codegen project: GenerateModuleJniH.js
9+
*/
10+
11+
#pragma once
12+
13+
#include <ReactCommon/JavaTurboModule.h>
14+
#include <ReactCommon/TurboModule.h>
15+
#include <jsi/jsi.h>
16+
17+
namespace facebook::react {
18+
19+
/**
20+
* JNI C++ class for module 'NativeAmplifyRtnPasskeys'
21+
*/
22+
class JSI_EXPORT NativeAmplifyRtnPasskeysSpecJSI : public JavaTurboModule {
23+
public:
24+
NativeAmplifyRtnPasskeysSpecJSI(const JavaTurboModule::InitParams &params);
25+
};
26+
27+
28+
JSI_EXPORT
29+
std::shared_ptr<TurboModule> AmplifyRtnPasskeysSpec_ModuleProvider(const std::string &moduleName, const JavaTurboModule::InitParams &params);
30+
31+
} // namespace facebook::react
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Copyright (c) Meta Platforms, Inc. and affiliates.
2+
#
3+
# This source code is licensed under the MIT license found in the
4+
# LICENSE file in the root directory of this source tree.
5+
6+
cmake_minimum_required(VERSION 3.13)
7+
set(CMAKE_VERBOSE_MAKEFILE on)
8+
9+
file(GLOB react_codegen_SRCS CONFIGURE_DEPENDS *.cpp react/renderer/components/AmplifyRtnPasskeysSpec/*.cpp)
10+
11+
add_library(
12+
react_codegen_AmplifyRtnPasskeysSpec
13+
OBJECT
14+
${react_codegen_SRCS}
15+
)
16+
17+
target_include_directories(react_codegen_AmplifyRtnPasskeysSpec PUBLIC . react/renderer/components/AmplifyRtnPasskeysSpec)
18+
19+
target_link_libraries(
20+
react_codegen_AmplifyRtnPasskeysSpec
21+
fbjni
22+
jsi
23+
# We need to link different libraries based on whether we are building rncore or not, that's necessary
24+
# because we want to break a circular dependency between react_codegen_rncore and reactnative
25+
reactnative
26+
)
27+
28+
target_compile_options(
29+
react_codegen_AmplifyRtnPasskeysSpec
30+
PRIVATE
31+
-DLOG_TAG=\"ReactNative\"
32+
-fexceptions
33+
-frtti
34+
-std=c++20
35+
-Wall
36+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3+
*
4+
* Do not edit this file as changes may cause incorrect behavior and will be lost
5+
* once the code is regenerated.
6+
*
7+
* @generated by codegen project: GenerateModuleCpp.js
8+
*/
9+
10+
#include "AmplifyRtnPasskeysSpecJSI.h"
11+
12+
namespace facebook::react {
13+
14+
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getIsPasskeySupported(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15+
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->getIsPasskeySupported(
16+
rt
17+
);
18+
}
19+
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_createPasskey(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
20+
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->createPasskey(
21+
rt,
22+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
23+
);
24+
}
25+
static jsi::Value __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getPasskey(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
26+
return static_cast<NativeAmplifyRtnPasskeysCxxSpecJSI *>(&turboModule)->getPasskey(
27+
rt,
28+
count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asObject(rt)
29+
);
30+
}
31+
32+
NativeAmplifyRtnPasskeysCxxSpecJSI::NativeAmplifyRtnPasskeysCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
33+
: TurboModule("AmplifyRtnPasskeys", jsInvoker) {
34+
methodMap_["getIsPasskeySupported"] = MethodMetadata {0, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getIsPasskeySupported};
35+
methodMap_["createPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_createPasskey};
36+
methodMap_["getPasskey"] = MethodMetadata {1, __hostFunction_NativeAmplifyRtnPasskeysCxxSpecJSI_getPasskey};
37+
}
38+
39+
40+
} // namespace facebook::react

0 commit comments

Comments
 (0)