react-native-nitro-passkeys 0.1.0
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/LICENSE +21 -0
- package/NitroPasskeys.podspec +37 -0
- package/README.md +314 -0
- package/android/CMakeLists.txt +31 -0
- package/android/build.gradle +155 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/nitropasskeys/HybridNitroPasskeys.kt +65 -0
- package/android/src/main/java/com/margelo/nitro/nitropasskeys/NitroPasskeysPackage.kt +20 -0
- package/android/src/main/java/com/margelo/nitro/nitropasskeys/PasskeyErrorToken.kt +64 -0
- package/android/src/test/java/com/margelo/nitro/nitropasskeys/PasskeyErrorTokenTest.kt +128 -0
- package/ios/Base64URL.swift +37 -0
- package/ios/Bridge.h +1 -0
- package/ios/HybridNitroPasskeys.swift +290 -0
- package/ios/PasskeyErrorToken.swift +32 -0
- package/ios/PasskeyJSON.swift +195 -0
- package/lib/commonjs/PasskeyError.js +39 -0
- package/lib/commonjs/PasskeyError.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/response.js +30 -0
- package/lib/commonjs/response.js.map +1 -0
- package/lib/commonjs/specs/nitro-passkeys.nitro.js +6 -0
- package/lib/commonjs/specs/nitro-passkeys.nitro.js.map +1 -0
- package/lib/commonjs/types.js +2 -0
- package/lib/commonjs/types.js.map +1 -0
- package/lib/commonjs/validate.js +118 -0
- package/lib/commonjs/validate.js.map +1 -0
- package/lib/module/PasskeyError.js +34 -0
- package/lib/module/PasskeyError.js.map +1 -0
- package/lib/module/index.js +42 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/response.js +25 -0
- package/lib/module/response.js.map +1 -0
- package/lib/module/specs/nitro-passkeys.nitro.js +4 -0
- package/lib/module/specs/nitro-passkeys.nitro.js.map +1 -0
- package/lib/module/types.js +2 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/validate.js +109 -0
- package/lib/module/validate.js.map +1 -0
- package/lib/typescript/example/server/index.d.ts +2 -0
- package/lib/typescript/example/server/index.d.ts.map +1 -0
- package/lib/typescript/src/PasskeyError.d.ts +8 -0
- package/lib/typescript/src/PasskeyError.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/response.d.ts +4 -0
- package/lib/typescript/src/response.d.ts.map +1 -0
- package/lib/typescript/src/specs/nitro-passkeys.nitro.d.ts +12 -0
- package/lib/typescript/src/specs/nitro-passkeys.nitro.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +104 -0
- package/lib/typescript/src/types.d.ts.map +1 -0
- package/lib/typescript/src/validate.d.ts +14 -0
- package/lib/typescript/src/validate.d.ts.map +1 -0
- package/nitro.json +24 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroPasskeys+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroPasskeys+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroPasskeysOnLoad.cpp +54 -0
- package/nitrogen/generated/android/NitroPasskeysOnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JHybridNitroPasskeysSpec.cpp +86 -0
- package/nitrogen/generated/android/c++/JHybridNitroPasskeysSpec.hpp +64 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitropasskeys/HybridNitroPasskeysSpec.kt +63 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitropasskeys/NitroPasskeysOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroPasskeys+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroPasskeys-Swift-Cxx-Bridge.cpp +49 -0
- package/nitrogen/generated/ios/NitroPasskeys-Swift-Cxx-Bridge.hpp +111 -0
- package/nitrogen/generated/ios/NitroPasskeys-Swift-Cxx-Umbrella.hpp +45 -0
- package/nitrogen/generated/ios/NitroPasskeysAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroPasskeysAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroPasskeysSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPasskeysSpecSwift.hpp +93 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridNitroPasskeysSpec.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridNitroPasskeysSpec_cxx.swift +169 -0
- package/nitrogen/generated/shared/c++/HybridNitroPasskeysSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridNitroPasskeysSpec.hpp +64 -0
- package/package.json +106 -0
- package/src/PasskeyError.ts +58 -0
- package/src/index.ts +66 -0
- package/src/response.ts +49 -0
- package/src/specs/nitro-passkeys.nitro.ts +12 -0
- package/src/types.ts +124 -0
- package/src/validate.ts +132 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroPasskeysSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridNitroPasskeysSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::nitropasskeys {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridNitroPasskeysSpec: public virtual HybridNitroPasskeysSpec, public virtual JHybridObject {
|
|
22
|
+
public:
|
|
23
|
+
struct JavaPart: public jni::JavaClass<JavaPart, JHybridObject::JavaPart> {
|
|
24
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitropasskeys/HybridNitroPasskeysSpec;";
|
|
25
|
+
std::shared_ptr<JHybridNitroPasskeysSpec> getJHybridNitroPasskeysSpec();
|
|
26
|
+
};
|
|
27
|
+
struct CxxPart: public jni::HybridClass<CxxPart, JHybridObject::CxxPart> {
|
|
28
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitropasskeys/HybridNitroPasskeysSpec$CxxPart;";
|
|
29
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
30
|
+
static void registerNatives();
|
|
31
|
+
using HybridBase::HybridBase;
|
|
32
|
+
protected:
|
|
33
|
+
std::shared_ptr<JHybridObject> createHybridObject(const jni::local_ref<JHybridObject::JavaPart>& javaPart) override;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
public:
|
|
37
|
+
explicit JHybridNitroPasskeysSpec(const jni::local_ref<JHybridNitroPasskeysSpec::JavaPart>& javaPart):
|
|
38
|
+
HybridObject(HybridNitroPasskeysSpec::TAG),
|
|
39
|
+
JHybridObject(javaPart),
|
|
40
|
+
_javaPart(jni::make_global(javaPart)) {}
|
|
41
|
+
~JHybridNitroPasskeysSpec() override {
|
|
42
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
43
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridNitroPasskeysSpec::JavaPart>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
bool getIsSupported() override;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
std::shared_ptr<Promise<std::string>> create(const std::string& creationOptionsJson) override;
|
|
58
|
+
std::shared_ptr<Promise<std::string>> get(const std::string& requestOptionsJson) override;
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
jni::global_ref<JHybridNitroPasskeysSpec::JavaPart> _javaPart;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
} // namespace margelo::nitro::nitropasskeys
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitropasskeys/HybridNitroPasskeysSpec.kt
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroPasskeysSpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitropasskeys
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import dalvik.annotation.optimization.FastNative
|
|
14
|
+
import com.margelo.nitro.core.Promise
|
|
15
|
+
import com.margelo.nitro.core.HybridObject
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A Kotlin class representing the NitroPasskeys HybridObject.
|
|
19
|
+
* Implement this abstract class to create Kotlin-based instances of NitroPasskeys.
|
|
20
|
+
*/
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
@Suppress(
|
|
24
|
+
"KotlinJniMissingFunction", "unused",
|
|
25
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
26
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
27
|
+
)
|
|
28
|
+
abstract class HybridNitroPasskeysSpec: HybridObject() {
|
|
29
|
+
// Properties
|
|
30
|
+
@get:DoNotStrip
|
|
31
|
+
@get:Keep
|
|
32
|
+
abstract val isSupported: Boolean
|
|
33
|
+
|
|
34
|
+
// Methods
|
|
35
|
+
@DoNotStrip
|
|
36
|
+
@Keep
|
|
37
|
+
abstract fun create(creationOptionsJson: String): Promise<String>
|
|
38
|
+
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
abstract fun get(requestOptionsJson: String): Promise<String>
|
|
42
|
+
|
|
43
|
+
// Default implementation of `HybridObject.toString()`
|
|
44
|
+
override fun toString(): String {
|
|
45
|
+
return "[HybridObject NitroPasskeys]"
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// C++ backing class
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
@Keep
|
|
51
|
+
protected open class CxxPart(javaPart: HybridNitroPasskeysSpec): HybridObject.CxxPart(javaPart) {
|
|
52
|
+
// C++ JHybridNitroPasskeysSpec::CxxPart::initHybrid(...)
|
|
53
|
+
@FastNative
|
|
54
|
+
external override fun initHybrid(): HybridData
|
|
55
|
+
}
|
|
56
|
+
override fun createCxxPart(): CxxPart {
|
|
57
|
+
return CxxPart(this)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
companion object {
|
|
61
|
+
protected const val TAG = "HybridNitroPasskeysSpec"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitropasskeys/NitroPasskeysOnLoad.kt
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeysOnLoad.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitropasskeys
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class NitroPasskeysOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "NitroPasskeysOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "NitroPasskeys".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading NitroPasskeys C++ library...")
|
|
25
|
+
System.loadLibrary("NitroPasskeys")
|
|
26
|
+
Log.i(TAG, "Successfully loaded NitroPasskeys C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load NitroPasskeys C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#
|
|
2
|
+
# NitroPasskeys+autolinking.rb
|
|
3
|
+
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
# https://github.com/mrousavy/nitro
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
# This is a Ruby script that adds all files generated by Nitrogen
|
|
9
|
+
# to the given podspec.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your .podspec:
|
|
12
|
+
# ```ruby
|
|
13
|
+
# Pod::Spec.new do |spec|
|
|
14
|
+
# # ...
|
|
15
|
+
#
|
|
16
|
+
# # Add all files generated by Nitrogen
|
|
17
|
+
# load 'nitrogen/generated/ios/NitroPasskeys+autolinking.rb'
|
|
18
|
+
# add_nitrogen_files(spec)
|
|
19
|
+
# end
|
|
20
|
+
# ```
|
|
21
|
+
|
|
22
|
+
def add_nitrogen_files(spec)
|
|
23
|
+
Pod::UI.puts "[NitroModules] 🔥 NitroPasskeys is boosted by nitro!"
|
|
24
|
+
|
|
25
|
+
spec.dependency "NitroModules"
|
|
26
|
+
|
|
27
|
+
current_source_files = Array(spec.attributes_hash['source_files'])
|
|
28
|
+
spec.source_files = current_source_files + [
|
|
29
|
+
# Generated cross-platform specs
|
|
30
|
+
"nitrogen/generated/shared/**/*.{h,hpp,c,cpp,swift}",
|
|
31
|
+
# Generated bridges for the cross-platform specs
|
|
32
|
+
"nitrogen/generated/ios/**/*.{h,hpp,c,cpp,mm,swift}",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
current_public_header_files = Array(spec.attributes_hash['public_header_files'])
|
|
36
|
+
spec.public_header_files = current_public_header_files + [
|
|
37
|
+
# Generated specs
|
|
38
|
+
"nitrogen/generated/shared/**/*.{h,hpp}",
|
|
39
|
+
# Swift to C++ bridging helpers
|
|
40
|
+
"nitrogen/generated/ios/NitroPasskeys-Swift-Cxx-Bridge.hpp"
|
|
41
|
+
]
|
|
42
|
+
|
|
43
|
+
current_private_header_files = Array(spec.attributes_hash['private_header_files'])
|
|
44
|
+
spec.private_header_files = current_private_header_files + [
|
|
45
|
+
# iOS specific specs
|
|
46
|
+
"nitrogen/generated/ios/c++/**/*.{h,hpp}",
|
|
47
|
+
# Views are framework-specific and should be private
|
|
48
|
+
"nitrogen/generated/shared/**/views/**/*"
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
current_pod_target_xcconfig = spec.attributes_hash['pod_target_xcconfig'] || {}
|
|
52
|
+
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
|
+
# Use C++ 20
|
|
54
|
+
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
|
+
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
|
+
# Enables stricter modular headers
|
|
58
|
+
"DEFINES_MODULE" => "YES",
|
|
59
|
+
# Disable auto-generated ObjC header for Swift (Static linkage on Xcode 26.4 breaks here)
|
|
60
|
+
"SWIFT_INSTALL_OBJC_HEADER" => "NO",
|
|
61
|
+
})
|
|
62
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeys-Swift-Cxx-Bridge.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "NitroPasskeys-Swift-Cxx-Bridge.hpp"
|
|
9
|
+
|
|
10
|
+
// Include C++ implementation defined types
|
|
11
|
+
#include "HybridNitroPasskeysSpecSwift.hpp"
|
|
12
|
+
#include "NitroPasskeys-Swift-Cxx-Umbrella.hpp"
|
|
13
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::nitropasskeys::bridge::swift {
|
|
16
|
+
|
|
17
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
18
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
19
|
+
auto swiftClosure = NitroPasskeys::Func_void_std__string::fromUnsafe(swiftClosureWrapper);
|
|
20
|
+
return [swiftClosure = std::move(swiftClosure)](const std::string& result) mutable -> void {
|
|
21
|
+
swiftClosure.call(result);
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
26
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
27
|
+
auto swiftClosure = NitroPasskeys::Func_void_std__exception_ptr::fromUnsafe(swiftClosureWrapper);
|
|
28
|
+
return [swiftClosure = std::move(swiftClosure)](const std::exception_ptr& error) mutable -> void {
|
|
29
|
+
swiftClosure.call(error);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// pragma MARK: std::shared_ptr<HybridNitroPasskeysSpec>
|
|
34
|
+
std::shared_ptr<HybridNitroPasskeysSpec> create_std__shared_ptr_HybridNitroPasskeysSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
35
|
+
NitroPasskeys::HybridNitroPasskeysSpec_cxx swiftPart = NitroPasskeys::HybridNitroPasskeysSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
36
|
+
return std::make_shared<margelo::nitro::nitropasskeys::HybridNitroPasskeysSpecSwift>(swiftPart);
|
|
37
|
+
}
|
|
38
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroPasskeysSpec_(std__shared_ptr_HybridNitroPasskeysSpec_ cppType) {
|
|
39
|
+
std::shared_ptr<margelo::nitro::nitropasskeys::HybridNitroPasskeysSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::nitropasskeys::HybridNitroPasskeysSpecSwift>(cppType);
|
|
40
|
+
#ifdef NITRO_DEBUG
|
|
41
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
42
|
+
throw std::runtime_error("Class \"HybridNitroPasskeysSpec\" is not implemented in Swift!");
|
|
43
|
+
}
|
|
44
|
+
#endif
|
|
45
|
+
NitroPasskeys::HybridNitroPasskeysSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
46
|
+
return swiftPart.toUnsafe();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
} // namespace margelo::nitro::nitropasskeys::bridge::swift
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeys-Swift-Cxx-Bridge.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridNitroPasskeysSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitropasskeys { class HybridNitroPasskeysSpec; }
|
|
13
|
+
|
|
14
|
+
// Forward declarations of Swift defined types
|
|
15
|
+
// Forward declaration of `HybridNitroPasskeysSpec_cxx` to properly resolve imports.
|
|
16
|
+
namespace NitroPasskeys { class HybridNitroPasskeysSpec_cxx; }
|
|
17
|
+
|
|
18
|
+
// Include C++ defined types
|
|
19
|
+
#include "HybridNitroPasskeysSpec.hpp"
|
|
20
|
+
#include <NitroModules/Promise.hpp>
|
|
21
|
+
#include <NitroModules/PromiseHolder.hpp>
|
|
22
|
+
#include <NitroModules/Result.hpp>
|
|
23
|
+
#include <exception>
|
|
24
|
+
#include <functional>
|
|
25
|
+
#include <memory>
|
|
26
|
+
#include <string>
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Contains specialized versions of C++ templated types so they can be accessed from Swift,
|
|
30
|
+
* as well as helper functions to interact with those C++ types from Swift.
|
|
31
|
+
*/
|
|
32
|
+
namespace margelo::nitro::nitropasskeys::bridge::swift {
|
|
33
|
+
|
|
34
|
+
// pragma MARK: std::shared_ptr<Promise<std::string>>
|
|
35
|
+
/**
|
|
36
|
+
* Specialized version of `std::shared_ptr<Promise<std::string>>`.
|
|
37
|
+
*/
|
|
38
|
+
using std__shared_ptr_Promise_std__string__ = std::shared_ptr<Promise<std::string>>;
|
|
39
|
+
inline std::shared_ptr<Promise<std::string>> create_std__shared_ptr_Promise_std__string__() noexcept {
|
|
40
|
+
return Promise<std::string>::create();
|
|
41
|
+
}
|
|
42
|
+
inline PromiseHolder<std::string> wrap_std__shared_ptr_Promise_std__string__(std::shared_ptr<Promise<std::string>> promise) noexcept {
|
|
43
|
+
return PromiseHolder<std::string>(std::move(promise));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// pragma MARK: std::function<void(const std::string& /* result */)>
|
|
47
|
+
/**
|
|
48
|
+
* Specialized version of `std::function<void(const std::string&)>`.
|
|
49
|
+
*/
|
|
50
|
+
using Func_void_std__string = std::function<void(const std::string& /* result */)>;
|
|
51
|
+
/**
|
|
52
|
+
* Wrapper class for a `std::function<void(const std::string& / * result * /)>`, this can be used from Swift.
|
|
53
|
+
*/
|
|
54
|
+
class Func_void_std__string_Wrapper final {
|
|
55
|
+
public:
|
|
56
|
+
explicit Func_void_std__string_Wrapper(std::function<void(const std::string& /* result */)>&& func): _function(std::make_unique<std::function<void(const std::string& /* result */)>>(std::move(func))) {}
|
|
57
|
+
inline void call(std::string result) const noexcept {
|
|
58
|
+
_function->operator()(result);
|
|
59
|
+
}
|
|
60
|
+
private:
|
|
61
|
+
std::unique_ptr<std::function<void(const std::string& /* result */)>> _function;
|
|
62
|
+
} SWIFT_NONCOPYABLE;
|
|
63
|
+
Func_void_std__string create_Func_void_std__string(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
64
|
+
inline Func_void_std__string_Wrapper wrap_Func_void_std__string(Func_void_std__string value) noexcept {
|
|
65
|
+
return Func_void_std__string_Wrapper(std::move(value));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// pragma MARK: std::function<void(const std::exception_ptr& /* error */)>
|
|
69
|
+
/**
|
|
70
|
+
* Specialized version of `std::function<void(const std::exception_ptr&)>`.
|
|
71
|
+
*/
|
|
72
|
+
using Func_void_std__exception_ptr = std::function<void(const std::exception_ptr& /* error */)>;
|
|
73
|
+
/**
|
|
74
|
+
* Wrapper class for a `std::function<void(const std::exception_ptr& / * error * /)>`, this can be used from Swift.
|
|
75
|
+
*/
|
|
76
|
+
class Func_void_std__exception_ptr_Wrapper final {
|
|
77
|
+
public:
|
|
78
|
+
explicit Func_void_std__exception_ptr_Wrapper(std::function<void(const std::exception_ptr& /* error */)>&& func): _function(std::make_unique<std::function<void(const std::exception_ptr& /* error */)>>(std::move(func))) {}
|
|
79
|
+
inline void call(std::exception_ptr error) const noexcept {
|
|
80
|
+
_function->operator()(error);
|
|
81
|
+
}
|
|
82
|
+
private:
|
|
83
|
+
std::unique_ptr<std::function<void(const std::exception_ptr& /* error */)>> _function;
|
|
84
|
+
} SWIFT_NONCOPYABLE;
|
|
85
|
+
Func_void_std__exception_ptr create_Func_void_std__exception_ptr(void* NON_NULL swiftClosureWrapper) noexcept;
|
|
86
|
+
inline Func_void_std__exception_ptr_Wrapper wrap_Func_void_std__exception_ptr(Func_void_std__exception_ptr value) noexcept {
|
|
87
|
+
return Func_void_std__exception_ptr_Wrapper(std::move(value));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// pragma MARK: std::shared_ptr<HybridNitroPasskeysSpec>
|
|
91
|
+
/**
|
|
92
|
+
* Specialized version of `std::shared_ptr<HybridNitroPasskeysSpec>`.
|
|
93
|
+
*/
|
|
94
|
+
using std__shared_ptr_HybridNitroPasskeysSpec_ = std::shared_ptr<HybridNitroPasskeysSpec>;
|
|
95
|
+
std::shared_ptr<HybridNitroPasskeysSpec> create_std__shared_ptr_HybridNitroPasskeysSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
96
|
+
void* NON_NULL get_std__shared_ptr_HybridNitroPasskeysSpec_(std__shared_ptr_HybridNitroPasskeysSpec_ cppType);
|
|
97
|
+
|
|
98
|
+
// pragma MARK: std::weak_ptr<HybridNitroPasskeysSpec>
|
|
99
|
+
using std__weak_ptr_HybridNitroPasskeysSpec_ = std::weak_ptr<HybridNitroPasskeysSpec>;
|
|
100
|
+
inline std__weak_ptr_HybridNitroPasskeysSpec_ weakify_std__shared_ptr_HybridNitroPasskeysSpec_(const std::shared_ptr<HybridNitroPasskeysSpec>& strong) noexcept { return strong; }
|
|
101
|
+
|
|
102
|
+
// pragma MARK: Result<std::shared_ptr<Promise<std::string>>>
|
|
103
|
+
using Result_std__shared_ptr_Promise_std__string___ = Result<std::shared_ptr<Promise<std::string>>>;
|
|
104
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::shared_ptr<Promise<std::string>>& value) noexcept {
|
|
105
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withValue(value);
|
|
106
|
+
}
|
|
107
|
+
inline Result_std__shared_ptr_Promise_std__string___ create_Result_std__shared_ptr_Promise_std__string___(const std::exception_ptr& error) noexcept {
|
|
108
|
+
return Result<std::shared_ptr<Promise<std::string>>>::withError(error);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
} // namespace margelo::nitro::nitropasskeys::bridge::swift
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeys-Swift-Cxx-Umbrella.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
// Forward declarations of C++ defined types
|
|
11
|
+
// Forward declaration of `HybridNitroPasskeysSpec` to properly resolve imports.
|
|
12
|
+
namespace margelo::nitro::nitropasskeys { class HybridNitroPasskeysSpec; }
|
|
13
|
+
|
|
14
|
+
// Include C++ defined types
|
|
15
|
+
#include "HybridNitroPasskeysSpec.hpp"
|
|
16
|
+
#include <NitroModules/Promise.hpp>
|
|
17
|
+
#include <NitroModules/Result.hpp>
|
|
18
|
+
#include <exception>
|
|
19
|
+
#include <memory>
|
|
20
|
+
#include <string>
|
|
21
|
+
|
|
22
|
+
// C++ helpers for Swift
|
|
23
|
+
#include "NitroPasskeys-Swift-Cxx-Bridge.hpp"
|
|
24
|
+
|
|
25
|
+
// Common C++ types used in Swift
|
|
26
|
+
#include <NitroModules/ArrayBufferHolder.hpp>
|
|
27
|
+
#include <NitroModules/AnyMapUtils.hpp>
|
|
28
|
+
#include <NitroModules/RuntimeError.hpp>
|
|
29
|
+
#include <NitroModules/DateToChronoDate.hpp>
|
|
30
|
+
|
|
31
|
+
// Forward declarations of Swift defined types
|
|
32
|
+
// Forward declaration of `HybridNitroPasskeysSpec_cxx` to properly resolve imports.
|
|
33
|
+
namespace NitroPasskeys { class HybridNitroPasskeysSpec_cxx; }
|
|
34
|
+
|
|
35
|
+
// Include Swift defined types
|
|
36
|
+
#if __has_include("NitroPasskeys-Swift.h")
|
|
37
|
+
// This header is generated by Xcode/Swift on every app build.
|
|
38
|
+
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "NitroPasskeys".
|
|
39
|
+
#include "NitroPasskeys-Swift.h"
|
|
40
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
|
41
|
+
#elif __has_include(<NitroPasskeys/NitroPasskeys-Swift.h>)
|
|
42
|
+
#include <NitroPasskeys/NitroPasskeys-Swift.h>
|
|
43
|
+
#else
|
|
44
|
+
#error NitroPasskeys's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "NitroPasskeys", and try building the app first.
|
|
45
|
+
#endif
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeysAutolinking.mm
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#import <Foundation/Foundation.h>
|
|
9
|
+
#import <NitroModules/HybridObjectRegistry.hpp>
|
|
10
|
+
#import "NitroPasskeys-Swift-Cxx-Umbrella.hpp"
|
|
11
|
+
#import <type_traits>
|
|
12
|
+
|
|
13
|
+
#include "HybridNitroPasskeysSpecSwift.hpp"
|
|
14
|
+
|
|
15
|
+
@interface NitroPasskeysAutolinking : NSObject
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
@implementation NitroPasskeysAutolinking
|
|
19
|
+
|
|
20
|
+
+ (void) load {
|
|
21
|
+
using namespace margelo::nitro;
|
|
22
|
+
using namespace margelo::nitro::nitropasskeys;
|
|
23
|
+
|
|
24
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
25
|
+
"NitroPasskeys",
|
|
26
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
27
|
+
std::shared_ptr<HybridNitroPasskeysSpec> hybridObject = NitroPasskeys::NitroPasskeysAutolinking::createNitroPasskeys();
|
|
28
|
+
return hybridObject;
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
@end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// NitroPasskeysAutolinking.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
// TODO: Use empty enums once Swift supports exporting them as namespaces
|
|
11
|
+
// See: https://github.com/swiftlang/swift/pull/83616
|
|
12
|
+
public final class NitroPasskeysAutolinking {
|
|
13
|
+
public typealias bridge = margelo.nitro.nitropasskeys.bridge.swift
|
|
14
|
+
|
|
15
|
+
public static func createNitroPasskeys() -> bridge.std__shared_ptr_HybridNitroPasskeysSpec_ {
|
|
16
|
+
let hybridObject = HybridNitroPasskeys()
|
|
17
|
+
return { () -> bridge.std__shared_ptr_HybridNitroPasskeysSpec_ in
|
|
18
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
19
|
+
return __cxxWrapped.getCxxPart()
|
|
20
|
+
}()
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public static func isNitroPasskeysRecyclable() -> Bool {
|
|
24
|
+
return HybridNitroPasskeys.self is any RecyclableView.Type
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroPasskeysSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridNitroPasskeysSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::nitropasskeys {
|
|
11
|
+
} // namespace margelo::nitro::nitropasskeys
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridNitroPasskeysSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridNitroPasskeysSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridNitroPasskeysSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace NitroPasskeys { class HybridNitroPasskeysSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <NitroModules/Promise.hpp>
|
|
19
|
+
|
|
20
|
+
#include "NitroPasskeys-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::nitropasskeys {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridNitroPasskeysSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridNitroPasskeysSpecSwift (C++) accesses HybridNitroPasskeysSpec_cxx (Swift), and might
|
|
28
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
29
|
+
*
|
|
30
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
31
|
+
* the future, HybridNitroPasskeysSpec_cxx can directly inherit from the C++ class HybridNitroPasskeysSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridNitroPasskeysSpecSwift: public virtual HybridNitroPasskeysSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridNitroPasskeysSpecSwift(const NitroPasskeys::HybridNitroPasskeysSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridNitroPasskeysSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline NitroPasskeys::HybridNitroPasskeysSpec_cxx& getSwiftPart() noexcept {
|
|
44
|
+
return _swiftPart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
49
|
+
return _swiftPart.getMemorySize();
|
|
50
|
+
}
|
|
51
|
+
bool equals(const std::shared_ptr<HybridObject>& other) override {
|
|
52
|
+
if (auto otherCast = std::dynamic_pointer_cast<HybridNitroPasskeysSpecSwift>(other)) {
|
|
53
|
+
return _swiftPart.equals(otherCast->_swiftPart);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
void dispose() noexcept override {
|
|
58
|
+
_swiftPart.dispose();
|
|
59
|
+
}
|
|
60
|
+
std::string toString() override {
|
|
61
|
+
return _swiftPart.toString();
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
// Properties
|
|
66
|
+
inline bool getIsSupported() noexcept override {
|
|
67
|
+
return _swiftPart.isSupported();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public:
|
|
71
|
+
// Methods
|
|
72
|
+
inline std::shared_ptr<Promise<std::string>> create(const std::string& creationOptionsJson) override {
|
|
73
|
+
auto __result = _swiftPart.create(creationOptionsJson);
|
|
74
|
+
if (__result.hasError()) [[unlikely]] {
|
|
75
|
+
std::rethrow_exception(__result.error());
|
|
76
|
+
}
|
|
77
|
+
auto __value = std::move(__result.value());
|
|
78
|
+
return __value;
|
|
79
|
+
}
|
|
80
|
+
inline std::shared_ptr<Promise<std::string>> get(const std::string& requestOptionsJson) override {
|
|
81
|
+
auto __result = _swiftPart.get(requestOptionsJson);
|
|
82
|
+
if (__result.hasError()) [[unlikely]] {
|
|
83
|
+
std::rethrow_exception(__result.error());
|
|
84
|
+
}
|
|
85
|
+
auto __value = std::move(__result.value());
|
|
86
|
+
return __value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private:
|
|
90
|
+
NitroPasskeys::HybridNitroPasskeysSpec_cxx _swiftPart;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro::nitropasskeys
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Func_void_std__exception_ptr.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
import NitroModules
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Wraps a Swift `(_ error: Error) -> Void` as a class.
|
|
12
|
+
* This class can be used from C++, e.g. to wrap the Swift closure as a `std::function`.
|
|
13
|
+
*/
|
|
14
|
+
public final class Func_void_std__exception_ptr {
|
|
15
|
+
public typealias bridge = margelo.nitro.nitropasskeys.bridge.swift
|
|
16
|
+
|
|
17
|
+
private let closure: (_ error: Error) -> Void
|
|
18
|
+
|
|
19
|
+
public init(_ closure: @escaping (_ error: Error) -> Void) {
|
|
20
|
+
self.closure = closure
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
@inline(__always)
|
|
24
|
+
public func call(error: std.exception_ptr) -> Void {
|
|
25
|
+
self.closure(RuntimeError.from(cppError: error))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Casts this instance to a retained unsafe raw pointer.
|
|
30
|
+
* This acquires one additional strong reference on the object!
|
|
31
|
+
*/
|
|
32
|
+
@inline(__always)
|
|
33
|
+
public func toUnsafe() -> UnsafeMutableRawPointer {
|
|
34
|
+
return Unmanaged.passRetained(self).toOpaque()
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Casts an unsafe pointer to a `Func_void_std__exception_ptr`.
|
|
39
|
+
* The pointer has to be a retained opaque `Unmanaged<Func_void_std__exception_ptr>`.
|
|
40
|
+
* This removes one strong reference from the object!
|
|
41
|
+
*/
|
|
42
|
+
@inline(__always)
|
|
43
|
+
public static func fromUnsafe(_ pointer: UnsafeMutableRawPointer) -> Func_void_std__exception_ptr {
|
|
44
|
+
return Unmanaged<Func_void_std__exception_ptr>.fromOpaque(pointer).takeRetainedValue()
|
|
45
|
+
}
|
|
46
|
+
}
|