react-native-nitro-auth 0.5.1 → 0.5.3
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 +362 -190
- package/android/src/main/java/com/auth/AuthAdapter.kt +55 -169
- package/android/src/main/java/com/auth/NitroAuthPackage.kt +1 -1
- package/app.plugin.js +2 -9
- package/cpp/AuthCache.cpp +12 -102
- package/cpp/HybridAuth.cpp +37 -61
- package/cpp/HybridAuth.hpp +2 -4
- package/ios/AuthAdapter.swift +21 -25
- package/lib/commonjs/Auth.web.js +433 -164
- package/lib/commonjs/Auth.web.js.map +1 -1
- package/lib/commonjs/index.js +0 -12
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.web.js +0 -12
- package/lib/commonjs/index.web.js.map +1 -1
- package/lib/commonjs/js-storage-adapter.js +2 -0
- package/lib/commonjs/js-storage-adapter.js.map +1 -0
- package/lib/commonjs/service.js +7 -84
- package/lib/commonjs/service.js.map +1 -1
- package/lib/commonjs/service.web.js +1 -5
- package/lib/commonjs/service.web.js.map +1 -1
- package/lib/commonjs/ui/social-button.js +44 -29
- package/lib/commonjs/ui/social-button.js.map +1 -1
- package/lib/commonjs/ui/social-button.web.js +44 -29
- package/lib/commonjs/ui/social-button.web.js.map +1 -1
- package/lib/commonjs/use-auth.js +8 -2
- package/lib/commonjs/use-auth.js.map +1 -1
- package/lib/commonjs/utils/logger.js +12 -4
- package/lib/commonjs/utils/logger.js.map +1 -1
- package/lib/module/Auth.web.js +433 -164
- package/lib/module/Auth.web.js.map +1 -1
- package/lib/module/index.js +0 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.web.js +0 -1
- package/lib/module/index.web.js.map +1 -1
- package/lib/module/js-storage-adapter.js +2 -0
- package/lib/module/js-storage-adapter.js.map +1 -0
- package/lib/module/service.js +7 -84
- package/lib/module/service.js.map +1 -1
- package/lib/module/service.web.js +1 -5
- package/lib/module/service.web.js.map +1 -1
- package/lib/module/ui/social-button.js +44 -29
- package/lib/module/ui/social-button.js.map +1 -1
- package/lib/module/ui/social-button.web.js +44 -29
- package/lib/module/ui/social-button.web.js.map +1 -1
- package/lib/module/use-auth.js +8 -2
- package/lib/module/use-auth.js.map +1 -1
- package/lib/module/utils/logger.js +12 -4
- package/lib/module/utils/logger.js.map +1 -1
- package/lib/typescript/commonjs/Auth.nitro.d.ts +3 -3
- package/lib/typescript/commonjs/Auth.nitro.d.ts.map +1 -1
- package/lib/typescript/commonjs/Auth.web.d.ts +18 -6
- package/lib/typescript/commonjs/Auth.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +1 -2
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.web.d.ts +0 -1
- package/lib/typescript/commonjs/index.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/js-storage-adapter.d.ts +6 -0
- package/lib/typescript/commonjs/js-storage-adapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/service.d.ts +1 -8
- package/lib/typescript/commonjs/service.d.ts.map +1 -1
- package/lib/typescript/commonjs/service.web.d.ts +1 -8
- package/lib/typescript/commonjs/service.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/social-button.d.ts +6 -6
- package/lib/typescript/commonjs/ui/social-button.d.ts.map +1 -1
- package/lib/typescript/commonjs/ui/social-button.web.d.ts +6 -6
- package/lib/typescript/commonjs/ui/social-button.web.d.ts.map +1 -1
- package/lib/typescript/commonjs/use-auth.d.ts +4 -4
- package/lib/typescript/commonjs/use-auth.d.ts.map +1 -1
- package/lib/typescript/commonjs/utils/logger.d.ts +4 -4
- package/lib/typescript/commonjs/utils/logger.d.ts.map +1 -1
- package/lib/typescript/module/Auth.nitro.d.ts +3 -3
- package/lib/typescript/module/Auth.nitro.d.ts.map +1 -1
- package/lib/typescript/module/Auth.web.d.ts +18 -6
- package/lib/typescript/module/Auth.web.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +1 -2
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/index.web.d.ts +0 -1
- package/lib/typescript/module/index.web.d.ts.map +1 -1
- package/lib/typescript/module/js-storage-adapter.d.ts +6 -0
- package/lib/typescript/module/js-storage-adapter.d.ts.map +1 -0
- package/lib/typescript/module/service.d.ts +1 -8
- package/lib/typescript/module/service.d.ts.map +1 -1
- package/lib/typescript/module/service.web.d.ts +1 -8
- package/lib/typescript/module/service.web.d.ts.map +1 -1
- package/lib/typescript/module/ui/social-button.d.ts +6 -6
- package/lib/typescript/module/ui/social-button.d.ts.map +1 -1
- package/lib/typescript/module/ui/social-button.web.d.ts +6 -6
- package/lib/typescript/module/ui/social-button.web.d.ts.map +1 -1
- package/lib/typescript/module/use-auth.d.ts +4 -4
- package/lib/typescript/module/use-auth.d.ts.map +1 -1
- package/lib/typescript/module/utils/logger.d.ts +4 -4
- package/lib/typescript/module/utils/logger.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroAuth+autolinking.cmake +0 -1
- package/nitrogen/generated/shared/c++/AuthTokens.hpp +5 -1
- package/nitrogen/generated/shared/c++/AuthUser.hpp +5 -1
- package/nitrogen/generated/shared/c++/HybridAuthSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridAuthSpec.hpp +0 -5
- package/package.json +11 -8
- package/src/Auth.nitro.ts +4 -3
- package/src/Auth.web.ts +582 -202
- package/src/global.d.ts +0 -1
- package/src/index.ts +1 -2
- package/src/index.web.ts +0 -1
- package/src/js-storage-adapter.ts +5 -0
- package/src/service.ts +11 -104
- package/src/service.web.ts +0 -7
- package/src/ui/social-button.tsx +66 -43
- package/src/ui/social-button.web.tsx +67 -44
- package/src/use-auth.ts +18 -6
- package/src/utils/logger.ts +12 -4
- package/lib/commonjs/AuthStorage.nitro.js +0 -6
- package/lib/commonjs/AuthStorage.nitro.js.map +0 -1
- package/lib/module/AuthStorage.nitro.js +0 -4
- package/lib/module/AuthStorage.nitro.js.map +0 -1
- package/lib/typescript/commonjs/AuthStorage.nitro.d.ts +0 -26
- package/lib/typescript/commonjs/AuthStorage.nitro.d.ts.map +0 -1
- package/lib/typescript/module/AuthStorage.nitro.d.ts +0 -26
- package/lib/typescript/module/AuthStorage.nitro.d.ts.map +0 -1
- package/nitrogen/generated/shared/c++/HybridAuthStorageAdapterSpec.cpp +0 -23
- package/nitrogen/generated/shared/c++/HybridAuthStorageAdapterSpec.hpp +0 -65
- package/src/AuthStorage.nitro.ts +0 -26
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EAKL,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,IAAI,EAKL,MAAM,cAAc,CAAC;AAGtB,eAAO,MAAM,WAAW,EAAE,IAkEzB,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type { AuthStorageAdapter } from "./AuthStorage.nitro";
|
|
2
|
-
import type { JSStorageAdapter } from "./service";
|
|
3
1
|
export declare const AuthService: {
|
|
4
2
|
name: string;
|
|
5
3
|
currentUser: import("./Auth.nitro").AuthUser | undefined;
|
|
@@ -10,17 +8,12 @@ export declare const AuthService: {
|
|
|
10
8
|
requestScopes: (scopes: string[]) => Promise<void>;
|
|
11
9
|
revokeScopes: (scopes: string[]) => Promise<void>;
|
|
12
10
|
getAccessToken: () => Promise<string | undefined>;
|
|
13
|
-
refreshToken: () => Promise<
|
|
14
|
-
accessToken?: string;
|
|
15
|
-
idToken?: string;
|
|
16
|
-
}>;
|
|
11
|
+
refreshToken: () => Promise<import("./Auth.nitro").AuthTokens>;
|
|
17
12
|
silentRestore: () => Promise<void>;
|
|
18
13
|
onAuthStateChanged: (callback: (user: import("./Auth.nitro").AuthUser | undefined) => void) => () => void;
|
|
19
14
|
onTokensRefreshed: (callback: (tokens: import("./Auth.nitro").AuthTokens) => void) => () => void;
|
|
20
15
|
setLoggingEnabled: (enabled: boolean) => void;
|
|
21
|
-
setStorageAdapter: (adapter: AuthStorageAdapter | undefined) => void;
|
|
22
16
|
dispose: () => void;
|
|
23
17
|
equals: (other: unknown) => boolean;
|
|
24
|
-
setJSStorageAdapter(adapter: JSStorageAdapter | undefined): void;
|
|
25
18
|
};
|
|
26
19
|
//# sourceMappingURL=service.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.web.d.ts","sourceRoot":"","sources":["../../../src/service.web.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"service.web.d.ts","sourceRoot":"","sources":["../../../src/service.web.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;CA+BvB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ViewStyle, TextStyle } from "react-native";
|
|
2
|
+
import type { ViewStyle, TextStyle } from "react-native";
|
|
3
3
|
import type { AuthProvider, AuthUser } from "../Auth.nitro";
|
|
4
|
-
|
|
4
|
+
export type SocialButtonVariant = "primary" | "outline" | "white" | "black";
|
|
5
|
+
export type SocialButtonProps = {
|
|
5
6
|
provider: AuthProvider;
|
|
6
|
-
variant?:
|
|
7
|
+
variant?: SocialButtonVariant;
|
|
7
8
|
borderRadius?: number;
|
|
8
9
|
style?: ViewStyle;
|
|
9
10
|
textStyle?: TextStyle;
|
|
@@ -11,7 +12,6 @@ interface SocialButtonProps {
|
|
|
11
12
|
onSuccess?: (user: AuthUser) => void;
|
|
12
13
|
onError?: (error: unknown) => void;
|
|
13
14
|
onPress?: () => void;
|
|
14
|
-
}
|
|
15
|
-
export declare const SocialButton: React.
|
|
16
|
-
export {};
|
|
15
|
+
};
|
|
16
|
+
export declare const SocialButton: ({ provider, variant, borderRadius, style, textStyle, disabled, onSuccess, onError, onPress, }: SocialButtonProps) => React.JSX.Element;
|
|
17
17
|
//# sourceMappingURL=social-button.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-button.d.ts","sourceRoot":"","sources":["../../../../src/ui/social-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"social-button.d.ts","sourceRoot":"","sources":["../../../../src/ui/social-button.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzD,OAAO,KAAK,EAAQ,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAElE,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAsCF,eAAO,MAAM,YAAY,GAAI,+FAU1B,iBAAiB,sBAiFnB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { ViewStyle, TextStyle } from "react-native";
|
|
2
|
+
import type { ViewStyle, TextStyle } from "react-native";
|
|
3
3
|
import type { AuthProvider, AuthUser } from "../Auth.nitro";
|
|
4
|
-
|
|
4
|
+
export type SocialButtonVariant = "primary" | "outline" | "white" | "black";
|
|
5
|
+
export type SocialButtonProps = {
|
|
5
6
|
provider: AuthProvider;
|
|
6
|
-
variant?:
|
|
7
|
+
variant?: SocialButtonVariant;
|
|
7
8
|
borderRadius?: number;
|
|
8
9
|
style?: ViewStyle;
|
|
9
10
|
textStyle?: TextStyle;
|
|
@@ -11,7 +12,6 @@ interface SocialButtonProps {
|
|
|
11
12
|
onSuccess?: (user: AuthUser) => void;
|
|
12
13
|
onError?: (error: unknown) => void;
|
|
13
14
|
onPress?: () => void;
|
|
14
|
-
}
|
|
15
|
-
export declare const SocialButton: React.
|
|
16
|
-
export {};
|
|
15
|
+
};
|
|
16
|
+
export declare const SocialButton: ({ provider, variant, borderRadius, style, textStyle, disabled, onSuccess, onError, onPress, }: SocialButtonProps) => React.JSX.Element;
|
|
17
17
|
//# sourceMappingURL=social-button.web.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"social-button.web.d.ts","sourceRoot":"","sources":["../../../../src/ui/social-button.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,
|
|
1
|
+
{"version":3,"file":"social-button.web.d.ts","sourceRoot":"","sources":["../../../../src/ui/social-button.web.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzD,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE5D,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,YAAY,CAAC;IACvB,OAAO,CAAC,EAAE,mBAAmB,CAAC;IAC9B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAqCF,eAAO,MAAM,YAAY,GAAI,+FAU1B,iBAAiB,sBAiFnB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { AuthUser, AuthProvider, LoginOptions, AuthTokens } from "./Auth.nitro";
|
|
2
|
-
|
|
2
|
+
type AuthState = {
|
|
3
3
|
user: AuthUser | undefined;
|
|
4
4
|
scopes: string[];
|
|
5
5
|
loading: boolean;
|
|
6
6
|
error: Error | undefined;
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
};
|
|
8
|
+
export type UseAuthReturn = AuthState & {
|
|
9
9
|
hasPlayServices: boolean;
|
|
10
10
|
login: (provider: AuthProvider, options?: LoginOptions) => Promise<void>;
|
|
11
11
|
logout: () => void;
|
|
@@ -14,7 +14,7 @@ export interface UseAuthReturn extends AuthState {
|
|
|
14
14
|
getAccessToken: () => Promise<string | undefined>;
|
|
15
15
|
refreshToken: () => Promise<AuthTokens>;
|
|
16
16
|
silentRestore: () => Promise<void>;
|
|
17
|
-
}
|
|
17
|
+
};
|
|
18
18
|
export declare function useAuth(): UseAuthReturn;
|
|
19
19
|
export {};
|
|
20
20
|
//# sourceMappingURL=use-auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../../src/use-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-auth.d.ts","sourceRoot":"","sources":["../../../src/use-auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACX,MAAM,cAAc,CAAC;AAGtB,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;CAC1B,CAAC;AAYF,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG;IACtC,eAAe,EAAE,OAAO,CAAC;IACzB,KAAK,EAAE,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,YAAY,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACnD,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,cAAc,EAAE,MAAM,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAClD,YAAY,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;IACxC,aAAa,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACpC,CAAC;AAEF,wBAAgB,OAAO,IAAI,aAAa,CAuKvC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const logger: {
|
|
2
2
|
setEnabled(value: boolean): void;
|
|
3
|
-
log: (...args: unknown[]) =>
|
|
4
|
-
warn: (...args: unknown[]) =>
|
|
5
|
-
error: (...args: unknown[]) =>
|
|
6
|
-
debug: (...args: unknown[]) =>
|
|
3
|
+
log: (...args: unknown[]) => void;
|
|
4
|
+
warn: (...args: unknown[]) => void;
|
|
5
|
+
error: (...args: unknown[]) => void;
|
|
6
|
+
debug: (...args: unknown[]) => void;
|
|
7
7
|
};
|
|
8
8
|
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;sBACC,OAAO,GAAG,IAAI;mBAGjB,OAAO,EAAE;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,MAAM;sBACC,OAAO,GAAG,IAAI;mBAGjB,OAAO,EAAE;oBAGR,OAAO,EAAE;qBAGR,OAAO,EAAE;qBAGT,OAAO,EAAE;CAG3B,CAAC"}
|
|
@@ -34,7 +34,6 @@ target_sources(
|
|
|
34
34
|
../nitrogen/generated/android/NitroAuthOnLoad.cpp
|
|
35
35
|
# Shared Nitrogen C++ sources
|
|
36
36
|
../nitrogen/generated/shared/c++/HybridAuthSpec.cpp
|
|
37
|
-
../nitrogen/generated/shared/c++/HybridAuthStorageAdapterSpec.cpp
|
|
38
37
|
# Android-specific Nitrogen C++ sources
|
|
39
38
|
|
|
40
39
|
)
|
|
@@ -42,11 +42,12 @@ namespace margelo::nitro::NitroAuth {
|
|
|
42
42
|
public:
|
|
43
43
|
std::optional<std::string> accessToken SWIFT_PRIVATE;
|
|
44
44
|
std::optional<std::string> idToken SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> refreshToken SWIFT_PRIVATE;
|
|
45
46
|
std::optional<double> expirationTime SWIFT_PRIVATE;
|
|
46
47
|
|
|
47
48
|
public:
|
|
48
49
|
AuthTokens() = default;
|
|
49
|
-
explicit AuthTokens(std::optional<std::string> accessToken, std::optional<std::string> idToken, std::optional<double> expirationTime): accessToken(accessToken), idToken(idToken), expirationTime(expirationTime) {}
|
|
50
|
+
explicit AuthTokens(std::optional<std::string> accessToken, std::optional<std::string> idToken, std::optional<std::string> refreshToken, std::optional<double> expirationTime): accessToken(accessToken), idToken(idToken), refreshToken(refreshToken), expirationTime(expirationTime) {}
|
|
50
51
|
|
|
51
52
|
public:
|
|
52
53
|
friend bool operator==(const AuthTokens& lhs, const AuthTokens& rhs) = default;
|
|
@@ -64,6 +65,7 @@ namespace margelo::nitro {
|
|
|
64
65
|
return margelo::nitro::NitroAuth::AuthTokens(
|
|
65
66
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken"))),
|
|
66
67
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
|
|
68
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "refreshToken"))),
|
|
67
69
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))
|
|
68
70
|
);
|
|
69
71
|
}
|
|
@@ -71,6 +73,7 @@ namespace margelo::nitro {
|
|
|
71
73
|
jsi::Object obj(runtime);
|
|
72
74
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accessToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
73
75
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "refreshToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.refreshToken));
|
|
74
77
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
75
78
|
return obj;
|
|
76
79
|
}
|
|
@@ -84,6 +87,7 @@ namespace margelo::nitro {
|
|
|
84
87
|
}
|
|
85
88
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken")))) return false;
|
|
86
89
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "refreshToken")))) return false;
|
|
87
91
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))) return false;
|
|
88
92
|
return true;
|
|
89
93
|
}
|
|
@@ -49,6 +49,7 @@ namespace margelo::nitro::NitroAuth {
|
|
|
49
49
|
std::optional<std::string> photo SWIFT_PRIVATE;
|
|
50
50
|
std::optional<std::string> idToken SWIFT_PRIVATE;
|
|
51
51
|
std::optional<std::string> accessToken SWIFT_PRIVATE;
|
|
52
|
+
std::optional<std::string> refreshToken SWIFT_PRIVATE;
|
|
52
53
|
std::optional<std::string> serverAuthCode SWIFT_PRIVATE;
|
|
53
54
|
std::optional<std::vector<std::string>> scopes SWIFT_PRIVATE;
|
|
54
55
|
std::optional<double> expirationTime SWIFT_PRIVATE;
|
|
@@ -56,7 +57,7 @@ namespace margelo::nitro::NitroAuth {
|
|
|
56
57
|
|
|
57
58
|
public:
|
|
58
59
|
AuthUser() = default;
|
|
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
|
+
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> refreshToken, 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), refreshToken(refreshToken), serverAuthCode(serverAuthCode), scopes(scopes), expirationTime(expirationTime), underlyingError(underlyingError) {}
|
|
60
61
|
|
|
61
62
|
public:
|
|
62
63
|
friend bool operator==(const AuthUser& lhs, const AuthUser& rhs) = default;
|
|
@@ -78,6 +79,7 @@ namespace margelo::nitro {
|
|
|
78
79
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photo"))),
|
|
79
80
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken"))),
|
|
80
81
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken"))),
|
|
82
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "refreshToken"))),
|
|
81
83
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"))),
|
|
82
84
|
JSIConverter<std::optional<std::vector<std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes"))),
|
|
83
85
|
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"))),
|
|
@@ -92,6 +94,7 @@ namespace margelo::nitro {
|
|
|
92
94
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "photo"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.photo));
|
|
93
95
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "idToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.idToken));
|
|
94
96
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "accessToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.accessToken));
|
|
97
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "refreshToken"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.refreshToken));
|
|
95
98
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.serverAuthCode));
|
|
96
99
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "scopes"), JSIConverter<std::optional<std::vector<std::string>>>::toJSI(runtime, arg.scopes));
|
|
97
100
|
obj.setProperty(runtime, PropNameIDCache::get(runtime, "expirationTime"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.expirationTime));
|
|
@@ -112,6 +115,7 @@ namespace margelo::nitro {
|
|
|
112
115
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "photo")))) return false;
|
|
113
116
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "idToken")))) return false;
|
|
114
117
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "accessToken")))) return false;
|
|
118
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "refreshToken")))) return false;
|
|
115
119
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "serverAuthCode")))) return false;
|
|
116
120
|
if (!JSIConverter<std::optional<std::vector<std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "scopes")))) return false;
|
|
117
121
|
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "expirationTime")))) return false;
|
|
@@ -27,7 +27,6 @@ namespace margelo::nitro::NitroAuth {
|
|
|
27
27
|
prototype.registerHybridMethod("onAuthStateChanged", &HybridAuthSpec::onAuthStateChanged);
|
|
28
28
|
prototype.registerHybridMethod("onTokensRefreshed", &HybridAuthSpec::onTokensRefreshed);
|
|
29
29
|
prototype.registerHybridMethod("setLoggingEnabled", &HybridAuthSpec::setLoggingEnabled);
|
|
30
|
-
prototype.registerHybridMethod("setStorageAdapter", &HybridAuthSpec::setStorageAdapter);
|
|
31
30
|
});
|
|
32
31
|
}
|
|
33
32
|
|
|
@@ -21,8 +21,6 @@ namespace margelo::nitro::NitroAuth { enum class AuthProvider; }
|
|
|
21
21
|
namespace margelo::nitro::NitroAuth { struct LoginOptions; }
|
|
22
22
|
// Forward declaration of `AuthTokens` to properly resolve imports.
|
|
23
23
|
namespace margelo::nitro::NitroAuth { struct AuthTokens; }
|
|
24
|
-
// Forward declaration of `HybridAuthStorageAdapterSpec` to properly resolve imports.
|
|
25
|
-
namespace margelo::nitro::NitroAuth { class HybridAuthStorageAdapterSpec; }
|
|
26
24
|
|
|
27
25
|
#include "AuthUser.hpp"
|
|
28
26
|
#include <optional>
|
|
@@ -33,8 +31,6 @@ namespace margelo::nitro::NitroAuth { class HybridAuthStorageAdapterSpec; }
|
|
|
33
31
|
#include "LoginOptions.hpp"
|
|
34
32
|
#include "AuthTokens.hpp"
|
|
35
33
|
#include <functional>
|
|
36
|
-
#include <memory>
|
|
37
|
-
#include "HybridAuthStorageAdapterSpec.hpp"
|
|
38
34
|
|
|
39
35
|
namespace margelo::nitro::NitroAuth {
|
|
40
36
|
|
|
@@ -79,7 +75,6 @@ namespace margelo::nitro::NitroAuth {
|
|
|
79
75
|
virtual std::function<void()> onAuthStateChanged(const std::function<void(const std::optional<AuthUser>& /* user */)>& callback) = 0;
|
|
80
76
|
virtual std::function<void()> onTokensRefreshed(const std::function<void(const AuthTokens& /* tokens */)>& callback) = 0;
|
|
81
77
|
virtual void setLoggingEnabled(bool enabled) = 0;
|
|
82
|
-
virtual void setStorageAdapter(const std::optional<std::shared_ptr<HybridAuthStorageAdapterSpec>>& adapter) = 0;
|
|
83
78
|
|
|
84
79
|
protected:
|
|
85
80
|
// Hybrid Setup
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-auth",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "High-performance authentication library for React Native with Google Sign-In, Apple Sign-In, and Microsoft Sign-In support, powered by Nitro Modules (JSI)",
|
|
5
5
|
"main": "lib/commonjs/index.js",
|
|
6
6
|
"module": "lib/module/index.js",
|
|
@@ -29,15 +29,18 @@
|
|
|
29
29
|
"!scripts"
|
|
30
30
|
],
|
|
31
31
|
"scripts": {
|
|
32
|
-
"prebuild": "
|
|
32
|
+
"prebuild": "bun run codegen",
|
|
33
33
|
"build": "bob build",
|
|
34
34
|
"clean": "rimraf lib nitrogen/generated",
|
|
35
35
|
"codegen": "nitrogen --logLevel=\"debug\"",
|
|
36
|
+
"lint": "eslint .",
|
|
36
37
|
"typecheck": "tsc --noEmit",
|
|
38
|
+
"format": "prettier --write .",
|
|
39
|
+
"format:check": "prettier --check .",
|
|
37
40
|
"test": "jest",
|
|
38
41
|
"test:coverage": "jest --coverage",
|
|
39
42
|
"test:cpp": "node scripts/test-cpp.js",
|
|
40
|
-
"prepublishOnly": "
|
|
43
|
+
"prepublishOnly": "bun run clean && bun run build",
|
|
41
44
|
"prepack": "node -e \"const fs=require('fs'); fs.copyFileSync('../../README.md','./README.md'); try{fs.copyFileSync('../../LICENSE','./LICENSE')}catch(e){}\"",
|
|
42
45
|
"postpack": "node -e \"const fs=require('fs'); ['./README.md','./LICENSE'].forEach(f=>fs.existsSync(f)&&fs.unlinkSync(f))\""
|
|
43
46
|
},
|
|
@@ -79,20 +82,20 @@
|
|
|
79
82
|
},
|
|
80
83
|
"devDependencies": {
|
|
81
84
|
"@expo/config-plugins": "^54.0.4",
|
|
82
|
-
"@react-native/babel-preset": "^0.81.
|
|
83
|
-
"@testing-library/react": "^16.
|
|
84
|
-
"@types/node": "^22.
|
|
85
|
+
"@react-native/babel-preset": "^0.81.6",
|
|
86
|
+
"@testing-library/react": "^16.3.2",
|
|
87
|
+
"@types/node": "^22.19.11",
|
|
85
88
|
"jest-environment-jsdom": "^29.7.0",
|
|
86
89
|
"react": "19.1.0",
|
|
87
90
|
"react-native": "0.81.5",
|
|
88
|
-
"react-native-nitro-modules": "^0.33.
|
|
91
|
+
"react-native-nitro-modules": "^0.33.9",
|
|
89
92
|
"react-native-web": "^0.21.2",
|
|
90
93
|
"typescript": "^5.9.3"
|
|
91
94
|
},
|
|
92
95
|
"peerDependencies": {
|
|
93
96
|
"react": "*",
|
|
94
97
|
"react-native": ">=0.75.0",
|
|
95
|
-
"react-native-nitro-modules": ">=0.33.
|
|
98
|
+
"react-native-nitro-modules": ">=0.33.9"
|
|
96
99
|
},
|
|
97
100
|
"react-native-builder-bob": {
|
|
98
101
|
"source": "src",
|
package/src/Auth.nitro.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { HybridObject } from "react-native-nitro-modules";
|
|
2
2
|
|
|
3
|
-
import type { AuthStorageAdapter } from "./AuthStorage.nitro";
|
|
4
|
-
|
|
5
3
|
export type AuthProvider = "google" | "apple" | "microsoft";
|
|
6
4
|
|
|
7
5
|
export type AuthErrorCode =
|
|
8
6
|
| "cancelled"
|
|
7
|
+
| "timeout"
|
|
8
|
+
| "popup_blocked"
|
|
9
9
|
| "network_error"
|
|
10
10
|
| "configuration_error"
|
|
11
11
|
| "unsupported_provider"
|
|
@@ -38,6 +38,7 @@ export interface LoginOptions {
|
|
|
38
38
|
export interface AuthTokens {
|
|
39
39
|
accessToken?: string;
|
|
40
40
|
idToken?: string;
|
|
41
|
+
refreshToken?: string;
|
|
41
42
|
expirationTime?: number;
|
|
42
43
|
}
|
|
43
44
|
|
|
@@ -48,6 +49,7 @@ export interface AuthUser {
|
|
|
48
49
|
photo?: string;
|
|
49
50
|
idToken?: string;
|
|
50
51
|
accessToken?: string;
|
|
52
|
+
refreshToken?: string;
|
|
51
53
|
serverAuthCode?: string;
|
|
52
54
|
scopes?: string[];
|
|
53
55
|
expirationTime?: number;
|
|
@@ -74,5 +76,4 @@ export interface Auth extends HybridObject<{ ios: "c++"; android: "c++" }> {
|
|
|
74
76
|
): () => void;
|
|
75
77
|
onTokensRefreshed(callback: (tokens: AuthTokens) => void): () => void;
|
|
76
78
|
setLoggingEnabled(enabled: boolean): void;
|
|
77
|
-
setStorageAdapter(adapter: AuthStorageAdapter | undefined): void;
|
|
78
79
|
}
|