react-native-nitro-auth 0.1.5 → 0.3.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/README.md +28 -11
- package/android/build.gradle +1 -1
- package/android/src/main/cpp/PlatformAuth+Android.cpp +22 -7
- package/android/src/main/java/com/auth/AuthAdapter.kt +15 -15
- package/app.plugin.js +7 -5
- package/ios/AuthAdapter.swift +37 -48
- package/ios/PlatformAuth+iOS.mm +32 -24
- package/lib/commonjs/Auth.web.js +14 -21
- package/lib/commonjs/Auth.web.js.map +1 -1
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/use-auth.js +5 -3
- package/lib/commonjs/use-auth.js.map +1 -1
- package/lib/module/Auth.web.js +14 -21
- package/lib/module/Auth.web.js.map +1 -1
- package/lib/module/package.json +1 -0
- package/lib/module/use-auth.js +5 -3
- package/lib/module/use-auth.js.map +1 -1
- package/lib/typescript/{Auth.nitro.d.ts → commonjs/Auth.nitro.d.ts} +4 -0
- package/lib/typescript/commonjs/Auth.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/Auth.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/AuthStorage.nitro.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/service.d.ts.map +1 -0
- package/lib/typescript/commonjs/service.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/social-button.d.ts.map +1 -0
- package/lib/typescript/commonjs/ui/social-button.web.d.ts.map +1 -0
- package/lib/typescript/commonjs/use-auth.d.ts.map +1 -0
- package/lib/typescript/commonjs/utils/logger.d.ts.map +1 -0
- package/lib/typescript/module/Auth.nitro.d.ts +48 -0
- package/lib/typescript/module/Auth.nitro.d.ts.map +1 -0
- package/lib/typescript/module/Auth.web.d.ts +40 -0
- package/lib/typescript/module/Auth.web.d.ts.map +1 -0
- package/lib/typescript/module/AuthStorage.nitro.d.ts +19 -0
- package/lib/typescript/module/AuthStorage.nitro.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +6 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/index.web.d.ts +6 -0
- package/lib/typescript/module/index.web.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/service.d.ts +3 -0
- package/lib/typescript/module/service.d.ts.map +1 -0
- package/lib/typescript/module/service.web.d.ts +2 -0
- package/lib/typescript/module/service.web.d.ts.map +1 -0
- package/lib/typescript/module/ui/social-button.d.ts +17 -0
- package/lib/typescript/module/ui/social-button.d.ts.map +1 -0
- package/lib/typescript/module/ui/social-button.web.d.ts +17 -0
- package/lib/typescript/module/ui/social-button.web.d.ts.map +1 -0
- package/lib/typescript/module/use-auth.d.ts +15 -0
- package/lib/typescript/module/use-auth.d.ts.map +1 -0
- package/lib/typescript/module/utils/logger.d.ts +8 -0
- package/lib/typescript/module/utils/logger.d.ts.map +1 -0
- package/nitrogen/generated/android/NitroAuth+autolinking.cmake +1 -1
- package/nitrogen/generated/android/NitroAuth+autolinking.gradle +1 -1
- package/nitrogen/generated/android/NitroAuthOnLoad.cpp +1 -1
- package/nitrogen/generated/android/NitroAuthOnLoad.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/auth/NitroAuthOnLoad.kt +1 -1
- package/nitrogen/generated/ios/NitroAuth+autolinking.rb +2 -2
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.hpp +1 -1
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Umbrella.hpp +1 -1
- package/nitrogen/generated/ios/NitroAuthAutolinking.mm +1 -1
- package/nitrogen/generated/ios/NitroAuthAutolinking.swift +5 -1
- package/nitrogen/generated/shared/c++/AuthProvider.hpp +1 -1
- package/nitrogen/generated/shared/c++/AuthTokens.hpp +19 -11
- package/nitrogen/generated/shared/c++/AuthUser.hpp +42 -30
- package/nitrogen/generated/shared/c++/HybridAuthSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridAuthSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridAuthStorageAdapterSpec.cpp +1 -1
- package/nitrogen/generated/shared/c++/HybridAuthStorageAdapterSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/LoginOptions.hpp +24 -12
- package/package.json +5 -4
- package/react-native-nitro-auth.podspec +1 -1
- package/src/Auth.nitro.ts +4 -0
- package/src/Auth.web.ts +17 -20
- package/src/use-auth.ts +5 -3
- package/lib/typescript/Auth.nitro.d.ts.map +0 -1
- package/lib/typescript/Auth.web.d.ts.map +0 -1
- package/lib/typescript/AuthStorage.nitro.d.ts.map +0 -1
- package/lib/typescript/index.d.ts.map +0 -1
- package/lib/typescript/index.web.d.ts.map +0 -1
- package/lib/typescript/service.d.ts.map +0 -1
- package/lib/typescript/service.web.d.ts.map +0 -1
- package/lib/typescript/ui/social-button.d.ts.map +0 -1
- package/lib/typescript/ui/social-button.web.d.ts.map +0 -1
- package/lib/typescript/use-auth.d.ts.map +0 -1
- package/lib/typescript/utils/logger.d.ts.map +0 -1
- /package/lib/typescript/{Auth.web.d.ts → commonjs/Auth.web.d.ts} +0 -0
- /package/lib/typescript/{AuthStorage.nitro.d.ts → commonjs/AuthStorage.nitro.d.ts} +0 -0
- /package/lib/typescript/{index.d.ts → commonjs/index.d.ts} +0 -0
- /package/lib/typescript/{index.web.d.ts → commonjs/index.web.d.ts} +0 -0
- /package/lib/typescript/{service.d.ts → commonjs/service.d.ts} +0 -0
- /package/lib/typescript/{service.web.d.ts → commonjs/service.web.d.ts} +0 -0
- /package/lib/typescript/{ui → commonjs/ui}/social-button.d.ts +0 -0
- /package/lib/typescript/{ui → commonjs/ui}/social-button.web.d.ts +0 -0
- /package/lib/typescript/{use-auth.d.ts → commonjs/use-auth.d.ts} +0 -0
- /package/lib/typescript/{utils → commonjs/utils}/logger.d.ts +0 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const logger: {
|
|
2
|
+
setEnabled: (value: boolean) => void;
|
|
3
|
+
log: (...args: any[]) => false | void;
|
|
4
|
+
warn: (...args: any[]) => false | void;
|
|
5
|
+
error: (...args: any[]) => false | void;
|
|
6
|
+
debug: (...args: any[]) => false | void;
|
|
7
|
+
};
|
|
8
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;wBACG,OAAO;mBAGZ,GAAG,EAAE;oBACJ,GAAG,EAAE;qBACJ,GAAG,EAAE;qBACL,GAAG,EAAE;CACvB,CAAC"}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroAuth+autolinking.cmake
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a CMake file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroAuth+autolinking.gradle
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroAuthOnLoad.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#ifndef BUILDING_NITROAUTH_WITH_GENERATED_CMAKE_PROJECT
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# NitroAuth+autolinking.rb
|
|
3
3
|
# This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
# https://github.com/mrousavy/nitro
|
|
5
|
-
# Copyright ©
|
|
5
|
+
# Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
#
|
|
7
7
|
|
|
8
8
|
# This is a Ruby script that adds all files generated by Nitrogen
|
|
@@ -52,7 +52,7 @@ def add_nitrogen_files(spec)
|
|
|
52
52
|
spec.pod_target_xcconfig = current_pod_target_xcconfig.merge({
|
|
53
53
|
# Use C++ 20
|
|
54
54
|
"CLANG_CXX_LANGUAGE_STANDARD" => "c++20",
|
|
55
|
-
# Enables C++ <-> Swift interop (by default it's only
|
|
55
|
+
# Enables C++ <-> Swift interop (by default it's only ObjC)
|
|
56
56
|
"SWIFT_OBJC_INTEROP_MODE" => "objcxx",
|
|
57
57
|
# Enables stricter modular headers
|
|
58
58
|
"DEFINES_MODULE" => "YES",
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroAuth-Swift-Cxx-Bridge.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "NitroAuth-Swift-Cxx-Bridge.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// NitroAuthAutolinking.mm
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#import <Foundation/Foundation.h>
|
|
@@ -2,9 +2,13 @@
|
|
|
2
2
|
/// NitroAuthAutolinking.swift
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
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
|
|
8
12
|
public final class NitroAuthAutolinking {
|
|
9
13
|
public typealias bridge = margelo.nitro.NitroAuth.bridge.swift
|
|
10
14
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// AuthTokens.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
#else
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
|
|
@@ -33,7 +38,7 @@ namespace margelo::nitro::NitroAuth {
|
|
|
33
38
|
/**
|
|
34
39
|
* A struct which can be represented as a JavaScript object (AuthTokens).
|
|
35
40
|
*/
|
|
36
|
-
struct AuthTokens {
|
|
41
|
+
struct AuthTokens final {
|
|
37
42
|
public:
|
|
38
43
|
std::optional<std::string> accessToken SWIFT_PRIVATE;
|
|
39
44
|
std::optional<std::string> idToken SWIFT_PRIVATE;
|
|
@@ -42,6 +47,9 @@ namespace margelo::nitro::NitroAuth {
|
|
|
42
47
|
public:
|
|
43
48
|
AuthTokens() = default;
|
|
44
49
|
explicit AuthTokens(std::optional<std::string> accessToken, std::optional<std::string> idToken, std::optional<double> expirationTime): accessToken(accessToken), idToken(idToken), expirationTime(expirationTime) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const AuthTokens& lhs, const AuthTokens& rhs) = default;
|
|
45
53
|
};
|
|
46
54
|
|
|
47
55
|
} // namespace margelo::nitro::NitroAuth
|
|
@@ -54,16 +62,16 @@ namespace margelo::nitro {
|
|
|
54
62
|
static inline margelo::nitro::NitroAuth::AuthTokens fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
63
|
jsi::Object obj = arg.asObject(runtime);
|
|
56
64
|
return margelo::nitro::NitroAuth::AuthTokens(
|
|
57
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "accessToken")),
|
|
58
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "idToken")),
|
|
59
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "expirationTime"))
|
|
65
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken"))),
|
|
66
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
|
|
67
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))
|
|
60
68
|
);
|
|
61
69
|
}
|
|
62
70
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::NitroAuth::AuthTokens& arg) {
|
|
63
71
|
jsi::Object obj(runtime);
|
|
64
|
-
obj.setProperty(runtime, "accessToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
65
|
-
obj.setProperty(runtime, "idToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
66
|
-
obj.setProperty(runtime, "expirationTime", JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
72
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accessToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
67
75
|
return obj;
|
|
68
76
|
}
|
|
69
77
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -74,9 +82,9 @@ namespace margelo::nitro {
|
|
|
74
82
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
75
83
|
return false;
|
|
76
84
|
}
|
|
77
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "accessToken"))) return false;
|
|
78
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "idToken"))) return false;
|
|
79
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "expirationTime"))) return false;
|
|
85
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken")))) return false;
|
|
86
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
|
|
87
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))) return false;
|
|
80
88
|
return true;
|
|
81
89
|
}
|
|
82
90
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// AuthUser.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
#else
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
25
30
|
|
|
26
31
|
// Forward declaration of `AuthProvider` to properly resolve imports.
|
|
27
32
|
namespace margelo::nitro::NitroAuth { enum class AuthProvider; }
|
|
@@ -36,7 +41,7 @@ namespace margelo::nitro::NitroAuth {
|
|
|
36
41
|
/**
|
|
37
42
|
* A struct which can be represented as a JavaScript object (AuthUser).
|
|
38
43
|
*/
|
|
39
|
-
struct AuthUser {
|
|
44
|
+
struct AuthUser final {
|
|
40
45
|
public:
|
|
41
46
|
AuthProvider provider SWIFT_PRIVATE;
|
|
42
47
|
std::optional<std::string> email SWIFT_PRIVATE;
|
|
@@ -47,10 +52,14 @@ namespace margelo::nitro::NitroAuth {
|
|
|
47
52
|
std::optional<std::string> serverAuthCode SWIFT_PRIVATE;
|
|
48
53
|
std::optional<std::vector<std::string>> scopes SWIFT_PRIVATE;
|
|
49
54
|
std::optional<double> expirationTime SWIFT_PRIVATE;
|
|
55
|
+
std::optional<std::string> underlyingError SWIFT_PRIVATE;
|
|
50
56
|
|
|
51
57
|
public:
|
|
52
58
|
AuthUser() = default;
|
|
53
|
-
explicit AuthUser(AuthProvider provider, std::optional<std::string> email, std::optional<std::string> name, std::optional<std::string> photo, std::optional<std::string> idToken, std::optional<std::string> accessToken, std::optional<std::string> serverAuthCode, std::optional<std::vector<std::string>> scopes, std::optional<double> expirationTime): provider(provider), email(email), name(name), photo(photo), idToken(idToken), accessToken(accessToken), serverAuthCode(serverAuthCode), scopes(scopes), expirationTime(expirationTime) {}
|
|
59
|
+
explicit AuthUser(AuthProvider provider, std::optional<std::string> email, std::optional<std::string> name, std::optional<std::string> photo, std::optional<std::string> idToken, std::optional<std::string> accessToken, std::optional<std::string> serverAuthCode, std::optional<std::vector<std::string>> scopes, std::optional<double> expirationTime, std::optional<std::string> underlyingError): provider(provider), email(email), name(name), photo(photo), idToken(idToken), accessToken(accessToken), serverAuthCode(serverAuthCode), scopes(scopes), expirationTime(expirationTime), underlyingError(underlyingError) {}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
friend bool operator==(const AuthUser& lhs, const AuthUser& rhs) = default;
|
|
54
63
|
};
|
|
55
64
|
|
|
56
65
|
} // namespace margelo::nitro::NitroAuth
|
|
@@ -63,28 +72,30 @@ namespace margelo::nitro {
|
|
|
63
72
|
static inline margelo::nitro::NitroAuth::AuthUser fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
73
|
jsi::Object obj = arg.asObject(runtime);
|
|
65
74
|
return margelo::nitro::NitroAuth::AuthUser(
|
|
66
|
-
JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::fromJSI(runtime, obj.getProperty(runtime, "provider")),
|
|
67
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "email")),
|
|
68
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "name")),
|
|
69
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "photo")),
|
|
70
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "idToken")),
|
|
71
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "accessToken")),
|
|
72
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "serverAuthCode")),
|
|
73
|
-
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "scopes")),
|
|
74
|
-
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, "expirationTime"))
|
|
75
|
+
JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "provider"))),
|
|
76
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email"))),
|
|
77
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
78
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photo"))),
|
|
79
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
|
|
80
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken"))),
|
|
81
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"))),
|
|
82
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes"))),
|
|
83
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"))),
|
|
84
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "underlyingError")))
|
|
75
85
|
);
|
|
76
86
|
}
|
|
77
87
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::NitroAuth::AuthUser& arg) {
|
|
78
88
|
jsi::Object obj(runtime);
|
|
79
|
-
obj.setProperty(runtime, "provider", JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::toJSI(runtime, arg.provider));
|
|
80
|
-
obj.setProperty(runtime, "email", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.email));
|
|
81
|
-
obj.setProperty(runtime, "name", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.name));
|
|
82
|
-
obj.setProperty(runtime, "photo", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.photo));
|
|
83
|
-
obj.setProperty(runtime, "idToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
84
|
-
obj.setProperty(runtime, "accessToken", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
85
|
-
obj.setProperty(runtime, "serverAuthCode", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.serverAuthCode));
|
|
86
|
-
obj.setProperty(runtime, "scopes", JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.scopes));
|
|
87
|
-
obj.setProperty(runtime, "expirationTime", JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "provider"), JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::toJSI(runtime, arg.provider));
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "email"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.email));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.name));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "photo"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.photo));
|
|
93
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
94
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accessToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
95
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.serverAuthCode));
|
|
96
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scopes"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.scopes));
|
|
97
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
98
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "underlyingError"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.underlyingError));
|
|
88
99
|
return obj;
|
|
89
100
|
}
|
|
90
101
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -95,15 +106,16 @@ namespace margelo::nitro {
|
|
|
95
106
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
96
107
|
return false;
|
|
97
108
|
}
|
|
98
|
-
if (!JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::canConvert(runtime, obj.getProperty(runtime, "provider"))) return false;
|
|
99
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "email"))) return false;
|
|
100
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "name"))) return false;
|
|
101
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "photo"))) return false;
|
|
102
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "idToken"))) return false;
|
|
103
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "accessToken"))) return false;
|
|
104
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "serverAuthCode"))) return false;
|
|
105
|
-
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, "scopes"))) return false;
|
|
106
|
-
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, "expirationTime"))) return false;
|
|
109
|
+
if (!JSIConverter<margelo::nitro::NitroAuth::AuthProvider>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "provider")))) return false;
|
|
110
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "email")))) return false;
|
|
111
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
112
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photo")))) return false;
|
|
113
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
|
|
114
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken")))) return false;
|
|
115
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode")))) return false;
|
|
116
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes")))) return false;
|
|
117
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))) return false;
|
|
118
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "underlyingError")))) return false;
|
|
107
119
|
return true;
|
|
108
120
|
}
|
|
109
121
|
};
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// HybridAuthStorageAdapterSpec.cpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#include "HybridAuthStorageAdapterSpec.hpp"
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/// LoginOptions.hpp
|
|
3
3
|
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
4
|
/// https://github.com/mrousavy/nitro
|
|
5
|
-
/// Copyright ©
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
6
|
///
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
@@ -22,6 +22,11 @@
|
|
|
22
22
|
#else
|
|
23
23
|
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
24
|
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
25
30
|
|
|
26
31
|
|
|
27
32
|
|
|
@@ -34,15 +39,19 @@ namespace margelo::nitro::NitroAuth {
|
|
|
34
39
|
/**
|
|
35
40
|
* A struct which can be represented as a JavaScript object (LoginOptions).
|
|
36
41
|
*/
|
|
37
|
-
struct LoginOptions {
|
|
42
|
+
struct LoginOptions final {
|
|
38
43
|
public:
|
|
39
44
|
std::optional<std::vector<std::string>> scopes SWIFT_PRIVATE;
|
|
40
45
|
std::optional<std::string> loginHint SWIFT_PRIVATE;
|
|
41
46
|
std::optional<bool> useOneTap SWIFT_PRIVATE;
|
|
47
|
+
std::optional<bool> useSheet SWIFT_PRIVATE;
|
|
42
48
|
|
|
43
49
|
public:
|
|
44
50
|
LoginOptions() = default;
|
|
45
|
-
explicit LoginOptions(std::optional<std::vector<std::string>> scopes, std::optional<std::string> loginHint, std::optional<bool> useOneTap): scopes(scopes), loginHint(loginHint), useOneTap(useOneTap) {}
|
|
51
|
+
explicit LoginOptions(std::optional<std::vector<std::string>> scopes, std::optional<std::string> loginHint, std::optional<bool> useOneTap, std::optional<bool> useSheet): scopes(scopes), loginHint(loginHint), useOneTap(useOneTap), useSheet(useSheet) {}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
friend bool operator==(const LoginOptions& lhs, const LoginOptions& rhs) = default;
|
|
46
55
|
};
|
|
47
56
|
|
|
48
57
|
} // namespace margelo::nitro::NitroAuth
|
|
@@ -55,16 +64,18 @@ namespace margelo::nitro {
|
|
|
55
64
|
static inline margelo::nitro::NitroAuth::LoginOptions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
56
65
|
jsi::Object obj = arg.asObject(runtime);
|
|
57
66
|
return margelo::nitro::NitroAuth::LoginOptions(
|
|
58
|
-
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, "scopes")),
|
|
59
|
-
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "loginHint")),
|
|
60
|
-
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "useOneTap"))
|
|
67
|
+
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes"))),
|
|
68
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "loginHint"))),
|
|
69
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useOneTap"))),
|
|
70
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useSheet")))
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::NitroAuth::LoginOptions& arg) {
|
|
64
74
|
jsi::Object obj(runtime);
|
|
65
|
-
obj.setProperty(runtime, "scopes", JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.scopes));
|
|
66
|
-
obj.setProperty(runtime, "loginHint", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.loginHint));
|
|
67
|
-
obj.setProperty(runtime, "useOneTap", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.useOneTap));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scopes"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.scopes));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "loginHint"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.loginHint));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "useOneTap"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.useOneTap));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "useSheet"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.useSheet));
|
|
68
79
|
return obj;
|
|
69
80
|
}
|
|
70
81
|
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
@@ -75,9 +86,10 @@ namespace margelo::nitro {
|
|
|
75
86
|
if (!nitro::isPlainObject(runtime, obj)) {
|
|
76
87
|
return false;
|
|
77
88
|
}
|
|
78
|
-
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, "scopes"))) return false;
|
|
79
|
-
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "loginHint"))) return false;
|
|
80
|
-
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "useOneTap"))) return false;
|
|
89
|
+
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "loginHint")))) return false;
|
|
91
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useOneTap")))) return false;
|
|
92
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "useSheet")))) return false;
|
|
81
93
|
return true;
|
|
82
94
|
}
|
|
83
95
|
};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-auth",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "High-performance authentication library for React Native with Google Sign-In and Apple Sign-In support, powered by Nitro Modules (JSI)",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
7
|
-
"types": "lib/typescript/index.d.ts",
|
|
7
|
+
"types": "lib/typescript/commonjs/index.d.ts",
|
|
8
8
|
"react-native": "src/index.ts",
|
|
9
9
|
"browser": "src/index.web.ts",
|
|
10
10
|
"source": "src/index.ts",
|
|
@@ -79,16 +79,17 @@
|
|
|
79
79
|
"@expo/config-plugins": "^54.0.4",
|
|
80
80
|
"@react-native/babel-preset": "^0.81.0",
|
|
81
81
|
"@testing-library/react": "^16.1.0",
|
|
82
|
+
"@types/node": "^22.14.0",
|
|
82
83
|
"jest-environment-jsdom": "^29.7.0",
|
|
83
84
|
"react": "19.1.0",
|
|
84
85
|
"react-native": "0.81.5",
|
|
85
|
-
"react-native-nitro-modules": "^0.
|
|
86
|
+
"react-native-nitro-modules": "^0.33.0",
|
|
86
87
|
"react-native-web": "^0.21.2"
|
|
87
88
|
},
|
|
88
89
|
"peerDependencies": {
|
|
89
90
|
"react": "*",
|
|
90
91
|
"react-native": ">=0.75.0",
|
|
91
|
-
"react-native-nitro-modules": ">=0.
|
|
92
|
+
"react-native-nitro-modules": ">=0.33.0"
|
|
92
93
|
},
|
|
93
94
|
"react-native-builder-bob": {
|
|
94
95
|
"source": "src",
|
package/src/Auth.nitro.ts
CHANGED
|
@@ -15,6 +15,8 @@ export interface LoginOptions {
|
|
|
15
15
|
scopes?: string[];
|
|
16
16
|
loginHint?: string;
|
|
17
17
|
useOneTap?: boolean;
|
|
18
|
+
/** (iOS only) Use native sign-in sheet */
|
|
19
|
+
useSheet?: boolean;
|
|
18
20
|
}
|
|
19
21
|
|
|
20
22
|
export interface AuthTokens {
|
|
@@ -33,6 +35,8 @@ export interface AuthUser {
|
|
|
33
35
|
serverAuthCode?: string;
|
|
34
36
|
scopes?: string[];
|
|
35
37
|
expirationTime?: number;
|
|
38
|
+
/** Raw native error message */
|
|
39
|
+
underlyingError?: string;
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
export interface Auth extends HybridObject<{ ios: "c++"; android: "c++" }> {
|
package/src/Auth.web.ts
CHANGED
|
@@ -183,25 +183,23 @@ class AuthWeb implements Auth {
|
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
private mapError(error: unknown): Error {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
return new Error("cancelled");
|
|
190
|
-
}
|
|
191
|
-
if (msg.includes("network")) {
|
|
192
|
-
return new Error("network_error");
|
|
193
|
-
}
|
|
194
|
-
if (msg.includes("client id") || msg.includes("config")) {
|
|
195
|
-
return new Error("configuration_error");
|
|
196
|
-
}
|
|
197
|
-
return error;
|
|
198
|
-
}
|
|
186
|
+
const rawMessage = error instanceof Error ? error.message : String(error);
|
|
187
|
+
const msg = rawMessage.toLowerCase();
|
|
188
|
+
let mappedMsg = rawMessage;
|
|
199
189
|
|
|
200
|
-
const msg = String(error).toLowerCase();
|
|
201
190
|
if (msg.includes("cancel") || msg.includes("popup_closed")) {
|
|
202
|
-
|
|
191
|
+
mappedMsg = "cancelled";
|
|
192
|
+
} else if (msg.includes("network")) {
|
|
193
|
+
mappedMsg = "network_error";
|
|
194
|
+
} else if (msg.includes("client id") || msg.includes("config")) {
|
|
195
|
+
mappedMsg = "configuration_error";
|
|
203
196
|
}
|
|
204
|
-
|
|
197
|
+
|
|
198
|
+
const authError = new Error(mappedMsg) as Error & {
|
|
199
|
+
underlyingError?: string;
|
|
200
|
+
};
|
|
201
|
+
authError.underlyingError = rawMessage;
|
|
202
|
+
return authError;
|
|
205
203
|
}
|
|
206
204
|
|
|
207
205
|
private async loginGoogle(
|
|
@@ -222,12 +220,11 @@ class AuthWeb implements Auth {
|
|
|
222
220
|
const authUrl = new URL("https://accounts.google.com/o/oauth2/v2/auth");
|
|
223
221
|
authUrl.searchParams.set("client_id", clientId);
|
|
224
222
|
authUrl.searchParams.set("redirect_uri", redirectUri);
|
|
225
|
-
// Requesting code alongside tokens for server-side verification if needed
|
|
226
223
|
authUrl.searchParams.set("response_type", "id_token token code");
|
|
227
224
|
authUrl.searchParams.set("scope", scopes.join(" "));
|
|
228
225
|
authUrl.searchParams.set("nonce", Math.random().toString(36).slice(2));
|
|
229
|
-
authUrl.searchParams.set("access_type", "offline");
|
|
230
|
-
authUrl.searchParams.set("prompt", "consent");
|
|
226
|
+
authUrl.searchParams.set("access_type", "offline");
|
|
227
|
+
authUrl.searchParams.set("prompt", "consent");
|
|
231
228
|
|
|
232
229
|
if (loginHint) {
|
|
233
230
|
authUrl.searchParams.set("login_hint", loginHint);
|
|
@@ -353,7 +350,7 @@ class AuthWeb implements Auth {
|
|
|
353
350
|
this.updateUser(user);
|
|
354
351
|
resolve();
|
|
355
352
|
})
|
|
356
|
-
.catch((
|
|
353
|
+
.catch((err: unknown) => reject(this.mapError(err)));
|
|
357
354
|
};
|
|
358
355
|
script.onerror = () => reject(new Error("Failed to load Apple SDK"));
|
|
359
356
|
document.head.appendChild(script);
|
package/src/use-auth.ts
CHANGED
|
@@ -112,13 +112,15 @@ export function useAuth() {
|
|
|
112
112
|
});
|
|
113
113
|
return tokens;
|
|
114
114
|
} catch (e) {
|
|
115
|
-
const
|
|
115
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
116
|
+
const authError = new Error(msg) as Error & { underlyingError?: string };
|
|
117
|
+
authError.underlyingError = AuthService.currentUser?.underlyingError;
|
|
116
118
|
setState((prev) => ({
|
|
117
119
|
...prev,
|
|
118
120
|
loading: false,
|
|
119
|
-
error,
|
|
121
|
+
error: authError,
|
|
120
122
|
}));
|
|
121
|
-
throw
|
|
123
|
+
throw authError;
|
|
122
124
|
}
|
|
123
125
|
}, []);
|
|
124
126
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Auth.nitro.d.ts","sourceRoot":"","sources":["../../src/Auth.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE9D,MAAM,MAAM,YAAY,GAAG,QAAQ,GAAG,OAAO,CAAC;AAE9C,MAAM,MAAM,aAAa,GACrB,WAAW,GACX,eAAe,GACf,qBAAqB,GACrB,sBAAsB,GACtB,SAAS,CAAC;AAEd,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,IAAK,SAAQ,YAAY,CAAC;IAAE,GAAG,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;IACxE,QAAQ,CAAC,WAAW,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IACjC,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAElC,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrE,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,cAAc,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9C,YAAY,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IAEpC,MAAM,IAAI,IAAI,CAAC;IAEf,kBAAkB,CAChB,QAAQ,EAAE,CAAC,IAAI,EAAE,QAAQ,GAAG,SAAS,KAAK,IAAI,GAC7C,MAAM,IAAI,CAAC;IACd,iBAAiB,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;IACtE,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAC1C,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,SAAS,GAAG,IAAI,CAAC;CAClE"}
|