react-native-nitro-auth 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/README.md +254 -0
- package/android/CMakeLists.txt +37 -0
- package/android/build.gradle +99 -0
- package/android/gradle.properties +4 -0
- package/android/src/main/AndroidManifest.xml +12 -0
- package/android/src/main/cpp/JniOnLoad.cpp +7 -0
- package/android/src/main/cpp/PlatformAuth+Android.cpp +293 -0
- package/android/src/main/java/com/auth/AuthAdapter.kt +286 -0
- package/android/src/main/java/com/auth/GoogleSignInActivity.kt +73 -0
- package/android/src/main/java/com/auth/NitroAuthModule.kt +19 -0
- package/android/src/main/java/com/auth/NitroAuthPackage.kt +16 -0
- package/app.plugin.js +64 -0
- package/cpp/AuthCache.cpp +105 -0
- package/cpp/AuthCache.hpp +20 -0
- package/cpp/HybridAuth.cpp +213 -0
- package/cpp/HybridAuth.hpp +47 -0
- package/cpp/JSONSerializer.hpp +57 -0
- package/cpp/PlatformAuth.hpp +25 -0
- package/ios/AuthAdapter.swift +200 -0
- package/ios/PlatformAuth+iOS.mm +119 -0
- package/lib/commonjs/Auth.nitro.js +6 -0
- package/lib/commonjs/Auth.nitro.js.map +1 -0
- package/lib/commonjs/Auth.web.js +256 -0
- package/lib/commonjs/Auth.web.js.map +1 -0
- package/lib/commonjs/global.d.js +6 -0
- package/lib/commonjs/global.d.js.map +1 -0
- package/lib/commonjs/index.js +52 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/index.web.js +52 -0
- package/lib/commonjs/index.web.js.map +1 -0
- package/lib/commonjs/service.js +9 -0
- package/lib/commonjs/service.js.map +1 -0
- package/lib/commonjs/service.web.js +13 -0
- package/lib/commonjs/service.web.js.map +1 -0
- package/lib/commonjs/ui/social-button.js +103 -0
- package/lib/commonjs/ui/social-button.js.map +1 -0
- package/lib/commonjs/ui/social-button.web.js +102 -0
- package/lib/commonjs/ui/social-button.web.js.map +1 -0
- package/lib/commonjs/use-auth.js +144 -0
- package/lib/commonjs/use-auth.js.map +1 -0
- package/lib/module/Auth.nitro.js +4 -0
- package/lib/module/Auth.nitro.js.map +1 -0
- package/lib/module/Auth.web.js +252 -0
- package/lib/module/Auth.web.js.map +1 -0
- package/lib/module/global.d.js +4 -0
- package/lib/module/global.d.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/index.web.js +7 -0
- package/lib/module/index.web.js.map +1 -0
- package/lib/module/service.js +5 -0
- package/lib/module/service.js.map +1 -0
- package/lib/module/service.web.js +4 -0
- package/lib/module/service.web.js.map +1 -0
- package/lib/module/ui/social-button.js +97 -0
- package/lib/module/ui/social-button.js.map +1 -0
- package/lib/module/ui/social-button.web.js +96 -0
- package/lib/module/ui/social-button.web.js.map +1 -0
- package/lib/module/use-auth.js +140 -0
- package/lib/module/use-auth.js.map +1 -0
- package/lib/typescript/Auth.nitro.d.ts +38 -0
- package/lib/typescript/Auth.nitro.d.ts.map +1 -0
- package/lib/typescript/Auth.web.d.ts +32 -0
- package/lib/typescript/Auth.web.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -0
- package/lib/typescript/index.d.ts.map +1 -0
- package/lib/typescript/index.web.d.ts +5 -0
- package/lib/typescript/index.web.d.ts.map +1 -0
- package/lib/typescript/service.d.ts +3 -0
- package/lib/typescript/service.d.ts.map +1 -0
- package/lib/typescript/service.web.d.ts +2 -0
- package/lib/typescript/service.web.d.ts.map +1 -0
- package/lib/typescript/ui/social-button.d.ts +17 -0
- package/lib/typescript/ui/social-button.d.ts.map +1 -0
- package/lib/typescript/ui/social-button.web.d.ts +17 -0
- package/lib/typescript/ui/social-button.web.d.ts.map +1 -0
- package/lib/typescript/use-auth.d.ts +15 -0
- package/lib/typescript/use-auth.d.ts.map +1 -0
- package/nitro.json +15 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroAuth+autolinking.cmake +81 -0
- package/nitrogen/generated/android/NitroAuth+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroAuthOnLoad.cpp +44 -0
- package/nitrogen/generated/android/NitroAuthOnLoad.hpp +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/com/auth/NitroAuthOnLoad.kt +35 -0
- package/nitrogen/generated/ios/NitroAuth+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Bridge.hpp +27 -0
- package/nitrogen/generated/ios/NitroAuth-Swift-Cxx-Umbrella.hpp +38 -0
- package/nitrogen/generated/ios/NitroAuthAutolinking.mm +35 -0
- package/nitrogen/generated/ios/NitroAuthAutolinking.swift +12 -0
- package/nitrogen/generated/shared/c++/AuthProvider.hpp +76 -0
- package/nitrogen/generated/shared/c++/AuthTokens.hpp +84 -0
- package/nitrogen/generated/shared/c++/AuthUser.hpp +107 -0
- package/nitrogen/generated/shared/c++/HybridAuthSpec.cpp +30 -0
- package/nitrogen/generated/shared/c++/HybridAuthSpec.hpp +85 -0
- package/nitrogen/generated/shared/c++/LoginOptions.hpp +81 -0
- package/package.json +113 -0
- package/react-native-nitro-auth.podspec +40 -0
- package/src/Auth.nitro.ts +50 -0
- package/src/Auth.web.ts +310 -0
- package/src/global.d.ts +38 -0
- package/src/index.ts +4 -0
- package/src/index.web.ts +4 -0
- package/src/service.ts +4 -0
- package/src/service.web.ts +1 -0
- package/src/ui/social-button.tsx +129 -0
- package/src/ui/social-button.web.tsx +128 -0
- package/src/use-auth.ts +157 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import GoogleSignIn
|
|
3
|
+
import AuthenticationServices
|
|
4
|
+
import NitroModules
|
|
5
|
+
import ObjectiveC
|
|
6
|
+
|
|
7
|
+
@objc
|
|
8
|
+
public class AuthAdapter: NSObject {
|
|
9
|
+
@objc
|
|
10
|
+
public static func login(provider: String, scopes: [String], loginHint: String?, completion: @escaping (NSDictionary?, String?) -> Void) {
|
|
11
|
+
if provider == "google" {
|
|
12
|
+
guard let clientId = Bundle.main.object(forInfoDictionaryKey: "GIDClientID") as? String, !clientId.isEmpty else {
|
|
13
|
+
completion(nil, "configuration_error")
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
DispatchQueue.main.async {
|
|
18
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
19
|
+
let rootVC = windowScene.windows.first?.rootViewController else {
|
|
20
|
+
completion(nil, "No root view controller found")
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let additionalScopes = scopes.isEmpty ? nil : scopes
|
|
25
|
+
GIDSignIn.sharedInstance.signIn(withPresenting: rootVC, hint: loginHint, additionalScopes: additionalScopes) { result, error in
|
|
26
|
+
if let error = error {
|
|
27
|
+
completion(nil, AuthAdapter.mapError(error))
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
guard let user = result?.user else {
|
|
32
|
+
completion(nil, "unknown")
|
|
33
|
+
return
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let data: [String: Any] = [
|
|
37
|
+
"provider": "google",
|
|
38
|
+
"email": user.profile?.email ?? "",
|
|
39
|
+
"name": user.profile?.name ?? "",
|
|
40
|
+
"photo": user.profile?.imageURL(withDimension: 300)?.absoluteString ?? "",
|
|
41
|
+
"idToken": user.idToken?.tokenString ?? "",
|
|
42
|
+
"accessToken": user.accessToken.tokenString,
|
|
43
|
+
"expirationTime": (user.accessToken.expirationDate?.timeIntervalSince1970 ?? 0) * 1000
|
|
44
|
+
]
|
|
45
|
+
completion(data as NSDictionary, nil)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
} else if provider == "apple" {
|
|
49
|
+
let appleIDProvider = ASAuthorizationAppleIDProvider()
|
|
50
|
+
let request = appleIDProvider.createRequest()
|
|
51
|
+
request.requestedScopes = [.fullName, .email]
|
|
52
|
+
|
|
53
|
+
let controller = ASAuthorizationController(authorizationRequests: [request])
|
|
54
|
+
let delegate = AppleSignInDelegate(completion: completion)
|
|
55
|
+
controller.delegate = delegate
|
|
56
|
+
objc_setAssociatedObject(controller, &delegateHandle, delegate, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
|
|
57
|
+
controller.performRequests()
|
|
58
|
+
} else {
|
|
59
|
+
completion(nil, "unsupported_provider")
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static func mapError(_ error: Error) -> String {
|
|
64
|
+
let nsError = error as NSError
|
|
65
|
+
if nsError.domain == "com.google.GIDSignIn" {
|
|
66
|
+
if nsError.code == -5 { return "cancelled" }
|
|
67
|
+
}
|
|
68
|
+
let msg = error.localizedDescription.lowercased()
|
|
69
|
+
if msg.contains("cancel") { return "cancelled" }
|
|
70
|
+
if msg.contains("network") { return "network_error" }
|
|
71
|
+
return "unknown"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@objc
|
|
75
|
+
public static func addScopes(scopes: [String], completion: @escaping (NSDictionary?, String?) -> Void) {
|
|
76
|
+
guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
|
|
77
|
+
completion(nil, "No Google user signed in")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
DispatchQueue.main.async {
|
|
82
|
+
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
|
|
83
|
+
let rootVC = windowScene.windows.first?.rootViewController else {
|
|
84
|
+
completion(nil, "No root view controller found")
|
|
85
|
+
return
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
currentUser.addScopes(scopes, presenting: rootVC) { result, error in
|
|
89
|
+
if let error = error {
|
|
90
|
+
completion(nil, AuthAdapter.mapError(error))
|
|
91
|
+
return
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
guard let user = result?.user else {
|
|
95
|
+
completion(nil, "unknown")
|
|
96
|
+
return
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let data: [String: Any] = [
|
|
100
|
+
"provider": "google",
|
|
101
|
+
"email": user.profile?.email ?? "",
|
|
102
|
+
"name": user.profile?.name ?? "",
|
|
103
|
+
"photo": user.profile?.imageURL(withDimension: 300)?.absoluteString ?? "",
|
|
104
|
+
"idToken": user.idToken?.tokenString ?? "",
|
|
105
|
+
"accessToken": user.accessToken.tokenString,
|
|
106
|
+
"expirationTime": (user.accessToken.expirationDate?.timeIntervalSince1970 ?? 0) * 1000
|
|
107
|
+
]
|
|
108
|
+
completion(data as NSDictionary, nil)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
@objc
|
|
114
|
+
public static func refreshToken(completion: @escaping (NSDictionary?, String?) -> Void) {
|
|
115
|
+
guard let currentUser = GIDSignIn.sharedInstance.currentUser else {
|
|
116
|
+
completion(nil, "No Google user signed in")
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
currentUser.refreshTokensIfNeeded { user, error in
|
|
121
|
+
if let error = error {
|
|
122
|
+
completion(nil, AuthAdapter.mapError(error))
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
guard let user = user else {
|
|
127
|
+
completion(nil, "unknown")
|
|
128
|
+
return
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
let data: [String: Any] = [
|
|
132
|
+
"accessToken": user.accessToken.tokenString,
|
|
133
|
+
"idToken": user.idToken?.tokenString ?? "",
|
|
134
|
+
"expirationTime": (user.accessToken.expirationDate?.timeIntervalSince1970 ?? 0) * 1000
|
|
135
|
+
]
|
|
136
|
+
completion(data as NSDictionary, nil)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@objc
|
|
141
|
+
public static func initialize(completion: @escaping (NSDictionary?) -> Void) {
|
|
142
|
+
guard Bundle.main.object(forInfoDictionaryKey: "GIDClientID") != nil else {
|
|
143
|
+
completion(nil)
|
|
144
|
+
return
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
GIDSignIn.sharedInstance.restorePreviousSignIn { user, error in
|
|
148
|
+
if let user = user {
|
|
149
|
+
let data: [String: Any] = [
|
|
150
|
+
"provider": "google",
|
|
151
|
+
"email": user.profile?.email ?? "",
|
|
152
|
+
"name": user.profile?.name ?? "",
|
|
153
|
+
"photo": user.profile?.imageURL(withDimension: 300)?.absoluteString ?? "",
|
|
154
|
+
"idToken": user.idToken?.tokenString ?? "",
|
|
155
|
+
"accessToken": user.accessToken.tokenString,
|
|
156
|
+
"expirationTime": (user.accessToken.expirationDate?.timeIntervalSince1970 ?? 0) * 1000
|
|
157
|
+
]
|
|
158
|
+
completion(data as NSDictionary)
|
|
159
|
+
return
|
|
160
|
+
}
|
|
161
|
+
completion(nil)
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
@objc
|
|
166
|
+
public static func logout() {
|
|
167
|
+
GIDSignIn.sharedInstance.signOut()
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
private var delegateHandle: UInt8 = 0
|
|
172
|
+
|
|
173
|
+
class AppleSignInDelegate: NSObject, ASAuthorizationControllerDelegate {
|
|
174
|
+
let completion: (NSDictionary?, String?) -> Void
|
|
175
|
+
|
|
176
|
+
init(completion: @escaping (NSDictionary?, String?) -> Void) {
|
|
177
|
+
self.completion = completion
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization) {
|
|
181
|
+
if let appleIDCredential = authorization.credential as? ASAuthorizationAppleIDCredential {
|
|
182
|
+
let email = appleIDCredential.email
|
|
183
|
+
let fullName = appleIDCredential.fullName
|
|
184
|
+
let name = [fullName?.givenName, fullName?.familyName].compactMap { $0 }.joined(separator: " ")
|
|
185
|
+
let idToken = appleIDCredential.identityToken.flatMap { String(data: $0, encoding: .utf8) }
|
|
186
|
+
|
|
187
|
+
let data: [String: Any] = [
|
|
188
|
+
"provider": "apple",
|
|
189
|
+
"email": email ?? "",
|
|
190
|
+
"name": name,
|
|
191
|
+
"idToken": idToken ?? ""
|
|
192
|
+
]
|
|
193
|
+
completion(data as NSDictionary, nil)
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error) {
|
|
198
|
+
completion(nil, AuthAdapter.mapError(error))
|
|
199
|
+
}
|
|
200
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
#import <NitroModules/Promise.hpp>
|
|
3
|
+
#import "AuthUser.hpp"
|
|
4
|
+
#import "AuthProvider.hpp"
|
|
5
|
+
#import "AuthTokens.hpp"
|
|
6
|
+
#import "PlatformAuth.hpp"
|
|
7
|
+
|
|
8
|
+
#if __has_include(<react_native_nitro_auth/react_native_nitro_auth-Swift.h>)
|
|
9
|
+
#import <react_native_nitro_auth/react_native_nitro_auth-Swift.h>
|
|
10
|
+
#elif __has_include("react_native_nitro_auth-Swift.h")
|
|
11
|
+
#import "react_native_nitro_auth-Swift.h"
|
|
12
|
+
#endif
|
|
13
|
+
|
|
14
|
+
namespace margelo::nitro::NitroAuth {
|
|
15
|
+
|
|
16
|
+
std::shared_ptr<Promise<AuthUser>> PlatformAuth::login(AuthProvider provider, const std::vector<std::string>& scopes, const std::optional<std::string>& loginHint) {
|
|
17
|
+
auto promise = Promise<AuthUser>::create();
|
|
18
|
+
NSString* providerStr = provider == AuthProvider::GOOGLE ? @"google" : @"apple";
|
|
19
|
+
NSMutableArray* scopesArray = [NSMutableArray arrayWithCapacity:scopes.size()];
|
|
20
|
+
for (const auto& scope : scopes) [scopesArray addObject:[NSString stringWithUTF8String:scope.c_str()]];
|
|
21
|
+
NSString* hintStr = loginHint.has_value() ? [NSString stringWithUTF8String:loginHint->c_str()] : nil;
|
|
22
|
+
|
|
23
|
+
[AuthAdapter loginWithProvider:providerStr scopes:scopesArray loginHint:hintStr completion:^(NSDictionary* _Nullable data, NSString* _Nullable error) {
|
|
24
|
+
if (error != nil) {
|
|
25
|
+
promise->reject(std::make_exception_ptr(std::runtime_error([error UTF8String])));
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (data == nil) {
|
|
29
|
+
promise->reject(std::make_exception_ptr(std::runtime_error("Login cancelled or failed")));
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
AuthUser user;
|
|
34
|
+
user.provider = provider;
|
|
35
|
+
user.email = std::string([[data objectForKey:@"email"] UTF8String]);
|
|
36
|
+
user.name = std::string([[data objectForKey:@"name"] UTF8String]);
|
|
37
|
+
user.photo = std::string([[data objectForKey:@"photo"] UTF8String]);
|
|
38
|
+
user.idToken = std::string([[data objectForKey:@"idToken"] UTF8String]);
|
|
39
|
+
if ([data objectForKey:@"accessToken"]) user.accessToken = std::string([[data objectForKey:@"accessToken"] UTF8String]);
|
|
40
|
+
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
41
|
+
|
|
42
|
+
promise->resolve(user);
|
|
43
|
+
}];
|
|
44
|
+
return promise;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
std::shared_ptr<Promise<AuthUser>> PlatformAuth::requestScopes(const std::vector<std::string>& scopes) {
|
|
48
|
+
auto promise = Promise<AuthUser>::create();
|
|
49
|
+
NSMutableArray* scopesArray = [NSMutableArray arrayWithCapacity:scopes.size()];
|
|
50
|
+
for (const auto& scope : scopes) [scopesArray addObject:[NSString stringWithUTF8String:scope.c_str()]];
|
|
51
|
+
|
|
52
|
+
[AuthAdapter addScopesWithScopes:scopesArray completion:^(NSDictionary* _Nullable data, NSString* _Nullable error) {
|
|
53
|
+
if (error != nil) {
|
|
54
|
+
promise->reject(std::make_exception_ptr(std::runtime_error([error UTF8String])));
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
if (data == nil) {
|
|
58
|
+
promise->reject(std::make_exception_ptr(std::runtime_error("Request scopes failed")));
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
AuthUser user;
|
|
63
|
+
user.provider = AuthProvider::GOOGLE;
|
|
64
|
+
user.email = std::string([[data objectForKey:@"email"] UTF8String]);
|
|
65
|
+
user.name = std::string([[data objectForKey:@"name"] UTF8String]);
|
|
66
|
+
user.photo = std::string([[data objectForKey:@"photo"] UTF8String]);
|
|
67
|
+
user.idToken = std::string([[data objectForKey:@"idToken"] UTF8String]);
|
|
68
|
+
if ([data objectForKey:@"accessToken"]) user.accessToken = std::string([[data objectForKey:@"accessToken"] UTF8String]);
|
|
69
|
+
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
70
|
+
promise->resolve(user);
|
|
71
|
+
}];
|
|
72
|
+
return promise;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
std::shared_ptr<Promise<AuthTokens>> PlatformAuth::refreshToken() {
|
|
76
|
+
auto promise = Promise<AuthTokens>::create();
|
|
77
|
+
[AuthAdapter refreshTokenWithCompletion:^(NSDictionary* _Nullable data, NSString* _Nullable error) {
|
|
78
|
+
if (error != nil) {
|
|
79
|
+
promise->reject(std::make_exception_ptr(std::runtime_error([error UTF8String])));
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
AuthTokens tokens;
|
|
83
|
+
if ([data objectForKey:@"accessToken"]) tokens.accessToken = std::string([[data objectForKey:@"accessToken"] UTF8String]);
|
|
84
|
+
if ([data objectForKey:@"idToken"]) tokens.idToken = std::string([[data objectForKey:@"idToken"] UTF8String]);
|
|
85
|
+
if ([data objectForKey:@"expirationTime"]) tokens.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
86
|
+
promise->resolve(tokens);
|
|
87
|
+
}];
|
|
88
|
+
return promise;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
std::shared_ptr<Promise<std::optional<AuthUser>>> PlatformAuth::silentRestore() {
|
|
92
|
+
auto promise = Promise<std::optional<AuthUser>>::create();
|
|
93
|
+
[AuthAdapter initializeWithCompletion:^(NSDictionary* _Nullable data) {
|
|
94
|
+
if (data == nil) {
|
|
95
|
+
promise->resolve(std::nullopt);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
AuthUser user;
|
|
99
|
+
user.provider = [[data objectForKey:@"provider"] isEqualToString:@"google"] ? AuthProvider::GOOGLE : AuthProvider::APPLE;
|
|
100
|
+
user.email = std::string([[data objectForKey:@"email"] UTF8String]);
|
|
101
|
+
user.name = std::string([[data objectForKey:@"name"] UTF8String]);
|
|
102
|
+
user.photo = std::string([[data objectForKey:@"photo"] UTF8String]);
|
|
103
|
+
user.idToken = std::string([[data objectForKey:@"idToken"] UTF8String]);
|
|
104
|
+
if ([data objectForKey:@"accessToken"]) user.accessToken = std::string([[data objectForKey:@"accessToken"] UTF8String]);
|
|
105
|
+
if ([data objectForKey:@"expirationTime"]) user.expirationTime = [[data objectForKey:@"expirationTime"] doubleValue];
|
|
106
|
+
promise->resolve(user);
|
|
107
|
+
}];
|
|
108
|
+
return promise;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
bool PlatformAuth::hasPlayServices() {
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
void PlatformAuth::logout() {
|
|
116
|
+
[AuthAdapter logout];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
} // namespace margelo::nitro::NitroAuth
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["Auth.nitro.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AuthModule = void 0;
|
|
7
|
+
const CACHE_KEY = "nitro_auth_user";
|
|
8
|
+
const SCOPES_KEY = "nitro_auth_scopes";
|
|
9
|
+
const DEFAULT_SCOPES = ["openid", "email", "profile"];
|
|
10
|
+
const getConfig = () => {
|
|
11
|
+
try {
|
|
12
|
+
const Constants = require("expo-constants").default;
|
|
13
|
+
return Constants.expoConfig?.extra || {};
|
|
14
|
+
} catch {
|
|
15
|
+
return {};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
class AuthWeb {
|
|
19
|
+
_grantedScopes = [];
|
|
20
|
+
_listeners = [];
|
|
21
|
+
constructor() {
|
|
22
|
+
const cached = localStorage.getItem(CACHE_KEY);
|
|
23
|
+
if (cached) {
|
|
24
|
+
try {
|
|
25
|
+
this._currentUser = JSON.parse(cached);
|
|
26
|
+
} catch {
|
|
27
|
+
localStorage.removeItem(CACHE_KEY);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const scopes = localStorage.getItem(SCOPES_KEY);
|
|
31
|
+
if (scopes) {
|
|
32
|
+
try {
|
|
33
|
+
this._grantedScopes = JSON.parse(scopes);
|
|
34
|
+
} catch {
|
|
35
|
+
localStorage.removeItem(SCOPES_KEY);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
get currentUser() {
|
|
40
|
+
return this._currentUser;
|
|
41
|
+
}
|
|
42
|
+
get grantedScopes() {
|
|
43
|
+
return this._grantedScopes;
|
|
44
|
+
}
|
|
45
|
+
get hasPlayServices() {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
onAuthStateChanged(callback) {
|
|
49
|
+
this._listeners.push(callback);
|
|
50
|
+
callback(this._currentUser);
|
|
51
|
+
return () => {
|
|
52
|
+
this._listeners = this._listeners.filter(l => l !== callback);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
notify() {
|
|
56
|
+
this._listeners.forEach(l => l(this._currentUser));
|
|
57
|
+
}
|
|
58
|
+
async login(provider, options) {
|
|
59
|
+
const scopes = options?.scopes ?? DEFAULT_SCOPES;
|
|
60
|
+
const loginHint = options?.loginHint;
|
|
61
|
+
try {
|
|
62
|
+
if (provider === "google") {
|
|
63
|
+
return await this.loginGoogle(scopes, loginHint);
|
|
64
|
+
}
|
|
65
|
+
return await this.loginApple();
|
|
66
|
+
} catch (e) {
|
|
67
|
+
throw this.mapError(e);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
async requestScopes(scopes) {
|
|
71
|
+
if (!this._currentUser) {
|
|
72
|
+
throw new Error("No user logged in");
|
|
73
|
+
}
|
|
74
|
+
if (this._currentUser.provider !== "google") {
|
|
75
|
+
throw new Error("Scope management only supported for Google");
|
|
76
|
+
}
|
|
77
|
+
const newScopes = [...new Set([...this._grantedScopes, ...scopes])];
|
|
78
|
+
return this.loginGoogle(newScopes).catch(e => {
|
|
79
|
+
throw this.mapError(e);
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
async revokeScopes(scopes) {
|
|
83
|
+
this._grantedScopes = this._grantedScopes.filter(s => !scopes.includes(s));
|
|
84
|
+
localStorage.setItem(SCOPES_KEY, JSON.stringify(this._grantedScopes));
|
|
85
|
+
if (this._currentUser) {
|
|
86
|
+
this._currentUser.scopes = this._grantedScopes;
|
|
87
|
+
this.updateUser(this._currentUser);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async getAccessToken() {
|
|
91
|
+
if (this._currentUser?.expirationTime) {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
if (now + 300000 > this._currentUser.expirationTime) {
|
|
94
|
+
await this.refreshToken();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return this._currentUser?.accessToken;
|
|
98
|
+
}
|
|
99
|
+
async refreshToken() {
|
|
100
|
+
if (!this._currentUser) {
|
|
101
|
+
throw new Error("No user logged in");
|
|
102
|
+
}
|
|
103
|
+
if (this._currentUser.provider !== "google") {
|
|
104
|
+
throw new Error("Token refresh only supported for Google");
|
|
105
|
+
}
|
|
106
|
+
await this.loginGoogle(this._grantedScopes.length > 0 ? this._grantedScopes : DEFAULT_SCOPES);
|
|
107
|
+
return {
|
|
108
|
+
accessToken: this._currentUser.accessToken,
|
|
109
|
+
idToken: this._currentUser.idToken
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
mapError(error) {
|
|
113
|
+
const msg = error?.message?.toLowerCase() ?? "";
|
|
114
|
+
if (msg.includes("cancel") || msg.includes("popup_closed")) {
|
|
115
|
+
return new Error("cancelled");
|
|
116
|
+
}
|
|
117
|
+
if (msg.includes("network")) {
|
|
118
|
+
return new Error("network_error");
|
|
119
|
+
}
|
|
120
|
+
if (msg.includes("client id") || msg.includes("config")) {
|
|
121
|
+
return new Error("configuration_error");
|
|
122
|
+
}
|
|
123
|
+
return error;
|
|
124
|
+
}
|
|
125
|
+
async loginGoogle(scopes, loginHint) {
|
|
126
|
+
const config = getConfig();
|
|
127
|
+
const clientId = config.googleWebClientId;
|
|
128
|
+
if (!clientId) {
|
|
129
|
+
throw new Error("Google Web Client ID not configured. Add 'GOOGLE_WEB_CLIENT_ID' to your .env file.");
|
|
130
|
+
}
|
|
131
|
+
return new Promise((resolve, reject) => {
|
|
132
|
+
const redirectUri = window.location.origin;
|
|
133
|
+
const authUrl = new URL("https://accounts.google.com/o/oauth2/v2/auth");
|
|
134
|
+
authUrl.searchParams.set("client_id", clientId);
|
|
135
|
+
authUrl.searchParams.set("redirect_uri", redirectUri);
|
|
136
|
+
authUrl.searchParams.set("response_type", "id_token token");
|
|
137
|
+
authUrl.searchParams.set("scope", scopes.join(" "));
|
|
138
|
+
authUrl.searchParams.set("nonce", Math.random().toString(36).slice(2));
|
|
139
|
+
if (loginHint) {
|
|
140
|
+
authUrl.searchParams.set("login_hint", loginHint);
|
|
141
|
+
}
|
|
142
|
+
const width = 500;
|
|
143
|
+
const height = 600;
|
|
144
|
+
const left = window.screenX + (window.outerWidth - width) / 2;
|
|
145
|
+
const top = window.screenY + (window.outerHeight - height) / 2;
|
|
146
|
+
const popup = window.open(authUrl.toString(), "google-auth", `width=${width},height=${height},left=${left},top=${top}`);
|
|
147
|
+
if (!popup) {
|
|
148
|
+
reject(new Error("Popup blocked. Please allow popups for this site."));
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const checkInterval = setInterval(() => {
|
|
152
|
+
try {
|
|
153
|
+
if (popup.closed) {
|
|
154
|
+
clearInterval(checkInterval);
|
|
155
|
+
reject(new Error("cancelled"));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const url = popup.location.href;
|
|
159
|
+
if (url.startsWith(redirectUri)) {
|
|
160
|
+
clearInterval(checkInterval);
|
|
161
|
+
popup.close();
|
|
162
|
+
const hash = new URL(url).hash.slice(1);
|
|
163
|
+
const params = new URLSearchParams(hash);
|
|
164
|
+
const idToken = params.get("id_token");
|
|
165
|
+
const accessToken = params.get("access_token");
|
|
166
|
+
const expiresIn = params.get("expires_in");
|
|
167
|
+
if (idToken) {
|
|
168
|
+
this._grantedScopes = scopes;
|
|
169
|
+
localStorage.setItem(SCOPES_KEY, JSON.stringify(scopes));
|
|
170
|
+
const user = {
|
|
171
|
+
provider: "google",
|
|
172
|
+
idToken,
|
|
173
|
+
accessToken: accessToken ?? undefined,
|
|
174
|
+
scopes,
|
|
175
|
+
expirationTime: expiresIn ? Date.now() + parseInt(expiresIn) * 1000 : undefined,
|
|
176
|
+
...this.decodeGoogleJwt(idToken)
|
|
177
|
+
};
|
|
178
|
+
this.updateUser(user);
|
|
179
|
+
resolve();
|
|
180
|
+
} else {
|
|
181
|
+
reject(new Error("No id_token in response"));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
} catch {}
|
|
185
|
+
}, 100);
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
decodeGoogleJwt(token) {
|
|
189
|
+
try {
|
|
190
|
+
const payload = token.split(".")[1];
|
|
191
|
+
const decoded = JSON.parse(atob(payload));
|
|
192
|
+
return {
|
|
193
|
+
email: decoded.email,
|
|
194
|
+
name: decoded.name,
|
|
195
|
+
photo: decoded.picture
|
|
196
|
+
};
|
|
197
|
+
} catch {
|
|
198
|
+
return {};
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
async loginApple() {
|
|
202
|
+
const config = getConfig();
|
|
203
|
+
const clientId = config.appleWebClientId;
|
|
204
|
+
if (!clientId) {
|
|
205
|
+
throw new Error("Apple Web Client ID not configured. Add 'APPLE_WEB_CLIENT_ID' to your .env file.");
|
|
206
|
+
}
|
|
207
|
+
return new Promise((resolve, reject) => {
|
|
208
|
+
const script = document.createElement("script");
|
|
209
|
+
script.src = "https://appleid.cdn-apple.com/appleauth/static/jsapi/appleid/1/en_US/appleid.auth.js";
|
|
210
|
+
script.async = true;
|
|
211
|
+
script.onload = () => {
|
|
212
|
+
if (!window.AppleID) {
|
|
213
|
+
reject(new Error("Apple SDK not loaded"));
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
window.AppleID.auth.init({
|
|
217
|
+
clientId,
|
|
218
|
+
scope: "name email",
|
|
219
|
+
redirectURI: window.location.origin,
|
|
220
|
+
usePopup: true
|
|
221
|
+
});
|
|
222
|
+
window.AppleID.auth.signIn().then(response => {
|
|
223
|
+
const user = {
|
|
224
|
+
provider: "apple",
|
|
225
|
+
idToken: response.authorization.id_token,
|
|
226
|
+
email: response.user?.email,
|
|
227
|
+
name: response.user?.name ? `${response.user.name.firstName} ${response.user.name.lastName}`.trim() : undefined
|
|
228
|
+
};
|
|
229
|
+
this.updateUser(user);
|
|
230
|
+
resolve();
|
|
231
|
+
}).catch(e => reject(this.mapError(e)));
|
|
232
|
+
};
|
|
233
|
+
script.onerror = () => reject(new Error("Failed to load Apple SDK"));
|
|
234
|
+
document.head.appendChild(script);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
logout() {
|
|
238
|
+
this._currentUser = undefined;
|
|
239
|
+
this._grantedScopes = [];
|
|
240
|
+
localStorage.removeItem(CACHE_KEY);
|
|
241
|
+
localStorage.removeItem(SCOPES_KEY);
|
|
242
|
+
this.notify();
|
|
243
|
+
}
|
|
244
|
+
updateUser(user) {
|
|
245
|
+
this._currentUser = user;
|
|
246
|
+
localStorage.setItem(CACHE_KEY, JSON.stringify(user));
|
|
247
|
+
this.notify();
|
|
248
|
+
}
|
|
249
|
+
name = "Auth";
|
|
250
|
+
dispose() {}
|
|
251
|
+
equals(other) {
|
|
252
|
+
return other === this;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
const AuthModule = exports.AuthModule = new AuthWeb();
|
|
256
|
+
//# sourceMappingURL=Auth.web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CACHE_KEY","SCOPES_KEY","DEFAULT_SCOPES","getConfig","Constants","require","default","expoConfig","extra","AuthWeb","_grantedScopes","_listeners","constructor","cached","localStorage","getItem","_currentUser","JSON","parse","removeItem","scopes","currentUser","grantedScopes","hasPlayServices","onAuthStateChanged","callback","push","filter","l","notify","forEach","login","provider","options","loginHint","loginGoogle","loginApple","e","mapError","requestScopes","Error","newScopes","Set","catch","revokeScopes","s","includes","setItem","stringify","updateUser","getAccessToken","expirationTime","now","Date","refreshToken","accessToken","length","idToken","error","msg","message","toLowerCase","config","clientId","googleWebClientId","Promise","resolve","reject","redirectUri","window","location","origin","authUrl","URL","searchParams","set","join","Math","random","toString","slice","width","height","left","screenX","outerWidth","top","screenY","outerHeight","popup","open","checkInterval","setInterval","closed","clearInterval","url","href","startsWith","close","hash","params","URLSearchParams","get","expiresIn","user","undefined","parseInt","decodeGoogleJwt","token","payload","split","decoded","atob","email","name","photo","picture","appleWebClientId","script","document","createElement","src","async","onload","AppleID","auth","init","scope","redirectURI","usePopup","signIn","then","response","authorization","id_token","firstName","lastName","trim","onerror","head","appendChild","logout","dispose","equals","other","AuthModule","exports"],"sourceRoot":"../../src","sources":["Auth.web.ts"],"mappings":";;;;;;AAEA,MAAMA,SAAS,GAAG,iBAAiB;AACnC,MA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;EACXC,MAAMA,CAACC,KAAU,EAAE;IACjB,OAAOA,KAAK,KAAK,IAAI;EACvB;AACF;AAEO,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIxI,OAAO,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["global.d.ts"],"mappings":"","ignoreList":[]}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
AuthService: true
|
|
8
|
+
};
|
|
9
|
+
Object.defineProperty(exports, "AuthService", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return _service.AuthService;
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
var _AuthNitro = require("./Auth.nitro.js");
|
|
16
|
+
Object.keys(_AuthNitro).forEach(function (key) {
|
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
19
|
+
if (key in exports && exports[key] === _AuthNitro[key]) return;
|
|
20
|
+
Object.defineProperty(exports, key, {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function () {
|
|
23
|
+
return _AuthNitro[key];
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
var _socialButton = require("./ui/social-button");
|
|
28
|
+
Object.keys(_socialButton).forEach(function (key) {
|
|
29
|
+
if (key === "default" || key === "__esModule") return;
|
|
30
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
31
|
+
if (key in exports && exports[key] === _socialButton[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _socialButton[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _useAuth = require("./use-auth.js");
|
|
40
|
+
Object.keys(_useAuth).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
43
|
+
if (key in exports && exports[key] === _useAuth[key]) return;
|
|
44
|
+
Object.defineProperty(exports, key, {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
get: function () {
|
|
47
|
+
return _useAuth[key];
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
var _service = require("./service");
|
|
52
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_AuthNitro","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_socialButton","_useAuth","_service"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,UAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,UAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,UAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,aAAA,GAAAb,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAW,aAAA,EAAAV,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA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